@
Mateusz W
When you see the first log 'success' in your console, that is coming from the 'console.log(result)' statement you wrote.
The second log 'Promise {: undefined}' is related to the '
promise1.then(result => console.log(result))
'. This is because the 'then' function itself returns a promise that resolves with the result you pass into it (in this case, you are not returning anything inside
then).
To better understand, consider the following code:
promise1.then(result => console.log(result)).then(result1 => {})
This will produce the output:
success
undefined
Promise {<fulfilled>: undefined}
The 'undefined' after 'success' corresponds to what you saw as 'Promise {: undefined}' and represents result1.
It's important not to mix up the
Promise {<fulfilled>: undefined}
you see here (from my code) with the
promise1 constant you defined. The former is the result of chaining a
second then to your initial
then call.
In summary, it might have been confusing thinking that the
Promise {<fulfilled>: undefined}
in your console referred to your
promise1. In reality, it indicates the return value of the
then function.