Consider this snippet.
Promise.resolve(1)
.then((v) => { v + 1; })
.then((v) => console.log(v));
Why does this print undefined, and what one-line change fixes it.
Hari ![]()
Consider this snippet.
Promise.resolve(1)
.then((v) => { v + 1; })
.then((v) => console.log(v));
Why does this print undefined, and what one-line change fixes it.
Hari ![]()
It prints undefined because the first then callback uses braces but does not return, so change it to .then(v => v + 1) or add return v + 1. inside the braces.
BobaMilk
:: Copyright KIRUPA 2024 //--