Why is promise resolving with undefined?

Because you've chained several promises together and one of your .then() handlers returns nothing.

This part:

.then((result) => {
  console.log('hello');
  // since there is no return value here, 
  // the promise chain's resolved value becomes undefined
});

returns nothing which is essentially the same as return undefined and therefore the resolved value of the chain becomes undefined.

You can change it to this to preserve the resolved value:

.then((result) => {
  console.log('hello');
  return result;         // preserve resolved value of the promise chain
});

Remember that the return value of every .then() handler becomes the resolved value of the chain going forward. No return value makes the resolved value be undefined.

Tags:

Promise