4 ms·
The argument passed to `resolve` gets returned from the resolve function and becomes available to any handler that handles it with `then`. In the above example,
by hoorayimhelping 7y ago
The argument passed to `resolve` gets returned from the resolve function and becomes available to any handler that handles it with `then`. In the above example, the object is being destructured as part of the arguments. The destructuring is probably what's tripping you up.
// straightforward, no magic
const simpleFunction = function() {
return Promise.resolve({ name: 'simpleObject' });
}
simpleFunction().then(function(response) {
console.log(response); // { name: 'simpleObject' }
});
// alternatively, destructuring the arguments
simpleFunction().then(function({ name }) {
console.log(name); // 'simpleObject'
});
- deleted 7y ago[deleted]
- korla 7y agoNo that is not what is tripping me up, or happening. The other answer explained it, some library code was executed aeaiting the location-promise.