Top "Fetch-api" questions

The Fetch API is an improved replacement for XHR, for making asynchronous HTTP requests while better managing redirects and interaction with CORS and Service Workers.

How do I post form data with fetch api?

My code: fetch("api/xxx", { body: new FormData(document.getElementById("form")), headers: { "Content-Type": "application/x-www-form-urlencoded", // "Content-Type": "multipart/form-data", }, method: "post", } …

javascript ajax fetch-api
fetch post with multipart form data

I am fetching a URL like this: fetch(url, { mode: 'no-cors', method: method || null, headers: { 'Accept': 'application/json, application/xml, …

javascript fetch fetch-api
What is an opaque response, and what purpose does it serve?

I tried to fetch the URL of an old website, and an error happened: Fetch API cannot load http://xyz. …

cors fetch-api
Fetch API request timeout?

I have a fetch-api POST request: fetch(url, { method: 'POST', body: formData, credentials: 'include' }) I want to know what is …

javascript ajax fetch-api
Basic authentication with fetch?

I want to write a simple basic authentication with fetch, but I keep getting a 401 error. It would be awesome …

javascript fetch-api
Getting "TypeError: failed to fetch" when the request hasn't actually failed

I'm using fetch API within my React app. The application was deployed on a server and was working perfectly. I …

javascript get fetch-api
fetch gives an empty response body

I have a react/redux application and I'm trying to do a simple GET request to a sever: fetch('http://…

javascript fetch-api
Post a x-www-form-urlencoded request from React Native

I have some parameters that I want to POST form-encoded to my server: { 'userName': '[email protected]', 'password': 'Password!', …

javascript http-post react-native fetch-api
Enable CORS in fetch api

I am getting the following error message that unable me to continue Failed to load https://site/data.json: Response …

javascript reactjs fetch-api
Why does .json() return a promise?

I've been messing around with the fetch() api recently, and noticed something which was a bit quirky. let url = "http://…

javascript asynchronous promise fetch-api