First my promise is fulfilled, then after I return it from a function it goes to pending when I log the status of the promise. Why is this?:
const createPromise = ()=> {
return new Promise((resolve, reject) => {
const data = 'Something';
if (data) {
resolve(data);
} else {
reject('Failed to load data');
}
});
};
const showData = async () => {
const data = createPromise(); // createPromise returns Promise<any>
console.log(data); // PromiseState 'fulfilled'
return data;
};
let promise = showData();
console.log(promise); // PromiseState 'pending'
console.log('print_something');
Why would the promise go from fulfilled to pending?
1