Your object is a promise (Promise), the real value is hidden inside the [[PromiseValue]]
slot. There is no access to this slot directly; you can only hook it out in two ways.
Method one is .then
method:
v.then(data => { console.log(data[0].msg1); console.log(data[1].msg2); console.log(data[2].msg3); })
Method two is via await
inside an asynchronous method:
data = await v; console.log(data[0].msg1); console.log(data[1].msg2); console.log(data[2].msg3);
But do not try to "deceive" the system and pull out the value earlier than it should! A promise is an abstraction of meaning that does not yet exist, but it will be available sometime in the future. That is why there is no way to “get” the value out of it right now.
If you try to do something like this:
let result; v.then(data => result = data); // не делайте так! console.log(result);
then you find out that nothing happened, the result variable remained undefined.
Why it turns out you can see if you look at the order of program execution:
let result; // 1 v.then(data => { result = data; // 4 }) // 2 console.log(result); // 3
First, it executes 1, then it executes the then
call (but the passed function has not yet been called!), Finally it executes 3, etc. And only much later, when some external event arrives, and control returns to the event queue, line 4 will be executed.