As long as there is a return statement (either explicit or implicit) in the callback function, both then and catch will return a promise (otherwise they'll return undefined).
In javascript, a function that doesn't return anything technically returns undefined, you can still chain those functions in a promise chain, it's just that the resolved value will be undefined.
fetchSomething().then(data=>{console.log(data)// This function doesn't return anything}).then(data=>{// data is undefined, but it's still wrapped inside a promise.})
Nice article, just a small comment.
In javascript, a function that doesn't return anything technically returns
undefined
, you can still chain those functions in a promise chain, it's just that the resolved value will beundefined
.Good catch! I guess I should reword that.
Thanks^