0

In Chrome DevTools, a resolved promise will return an interactive object that can be expanded and collapsed, like so;

> Promise.resolve('foo')
< ▶ Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: "foo"}

In Node, a resolved promise will return a string;

> Promise.resolve('foo')
< Promise { 'x' }

What, and who, determines what is returned to the console when visualising a variable? Is this standardised somehow?

William Boman
  • 2,079
  • 5
  • 26
  • 39

1 Answers1

1

So you can format your console logs, here are the basics https://developer.mozilla.org/en-US/docs/Web/API/Console/log

you can also do colors and such, which is discussed here:

How do I create formatted javascript console log messages

Also from your example, that might be two totally different Promises (librabies) that are being returned. What version of Node are you running?

Each browser also implements console differently so you wont get the same response across browsers or from chrome to node. There are node libraries that will allow you to add to your console (formatting and such) but I dont think there are any that make it interactive (because you would have to make the ui interactive which is true for a browser but not for output in a terminal)

Community
  • 1
  • 1
YourGoodFriend
  • 943
  • 15
  • 22