Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAustin Schneider
4,919 PointsTerminal says pending, but after changes won't resolve and show message.
Finally got the terminal to say pending, but after adding resolve and breakfastPromise.then() it won't resolve and print the message. Help!
const breakfastPromise = new Promise( (resolve, reject) => {
setTimeout (() => {
resolve('Your order is ready. Come and get it!');
}, 3000);
});
console.log(breakfastPromise);
breakfastPromise.then( val => console.log(val) );
Let me know if you see anything wrong! I've been stuck on this for days. Took me several just to get vs code to run node on promises-breakfast!
2 Answers
Blake Larson
13,014 PointsI ran it in node and it resolved like it should.
const breakfastPromise = new Promise( (resolve, reject) => {
setTimeout (() => {
resolve('Your order is ready. Come and get it!');
}, 3000);
});
console.log(breakfastPromise);
breakfastPromise.then( val => {
console.log(val)
console.log(breakfastPromise);
});
/////// OUTPUT
$ node app.js // I just ran it in a quick app.js file
Promise { <pending> }
Your order is ready. Come and get it!
Promise { 'Your order is ready. Come and get it!' }
Thomas Davidson
7,243 PointsI had a similar issue, try hitting ctrl+s before running in the console, that seemed to solve it for me