In my code I'm fetching the data then processing JSON inside it like this:
new BluebirdPromise((resolve, reject) => {
fetch(url)
.then(response => {
response.json().then(data => ({
resolve();
})
})
.catch(console.log);
});
this gives me a warning:
Warning: a promise was created in a handler at handler but never returned from it
Im still getting the warning even if i do it like this:
return fetch(url)
.then(response => {
return response.json().then(data => ({
resolve();
//to make sure warning will not show up
return null;
})
})
.catch(console.log);
Am I missing something here?
The reason I'm creating a bluebird promise is because I need an ability to cancel the request. Within this promise I have a fetch that creates another promise (non-cancelable). Besides that I have additional logic after the fetch resolves, that analyzes the returned result & resolves or rejects the BluebirdPromise. This still generates a warning:
return new BluebirdPromise((resolve, reject) => {
return fetch(EndPoint, {})
.then(() => {
return resolve(1);
})
.catch();
});
}