Fetch may cause an error and you have not added a catch block. Try the following:
return fetch(url, options) .then((resp) => { if (resp.ok) { return resp.json() .then((responseData) => { return responseData; }); } return resp.json() .then((error) => { return Promise.reject(error); }); }) .catch(err => {});
Remember that Promises usually has this format:
promise(params) .then(resp => { }, cause => {}) .catch(error => { });
I use it that way because I used to run into the same problem.
Let me know if this helps you.
source share