samedi 26 janvier 2019

Processing fetch response - JS

I have the response after GET-request with fetch. I know that this response will return an Array. When I process it with .json() - everything is fine. But when I try to process same response with .formData()- it fails. Here's the code:

fetch(fullPath)
    .then(response => response.json())
    .then((allData) => {
      console.log(allData);
    })
    .catch((e) => console.log(e));

same one with response.formData() doesn't work. So the question is - why we are not able to process the promise in first "then" with .formData() if the off. doc says that formData() is also acceptable method for extracting body from the response ?




Aucun commentaire:

Enregistrer un commentaire