Skip to main content

Fetch API

The Fetch API provides an interface for executing network calls programmatically. You can use fetch() to programmatically configure and execute a REST API.


GET request

const questions = await fetch("")
return questions.json()

POST request

fetch("", {
method: "POST",
headers: {
"Content-Type": "application/json",
body: JSON.stringify({
name: "Alex",
email: "",
}).then((response) => {
console.log("Success:", response.json());
}).catch((error) => {
console.error("Error:", error);

File upload

const formData = new FormData();
formData.append("file", FilePicker1.files[0]);

let response = await fetch('', {
method: 'POST',
body: formData