- From: vaibhav sharma <notifications@github.com>
- Date: Sun, 29 Mar 2020 05:08:33 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Sunday, 29 March 2020 12:08:51 UTC
I prefer to do like this ```return new Promise((resolve, reject) => { fetch(url, { method: POST, headers, body: JSON.stringify(body), }) .then((res) => { const response = res; const responsePromise = res.json(); responsePromise .then((data) => { if (response.status >= 400) { reject(data); } else { resolve(data); } }) .catch((error) => { reject(error); }); }); }); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/18#issuecomment-605626293
Received on Sunday, 29 March 2020 12:08:51 UTC