I'm trying to get the result of a fetch in an asynchronous way like this:
var result = await fetch(`/api/collection/get-collection.php?name=${this._name}`, {method: `GET`});
console.log(result.json());
but when I look at the console I get this:
Promise {<pending>}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: Object
content: (176) [...]
extra: {...}
message: ...
__proto__: Object
So I feel like when it comes to the console.log the promise is still pending? (there's a tooltip saying "Value below was evaluated just now" so I guess it's updated when the promise is resolved? And of course the code below (not shown here) doesn't work cause it needs the value of fetch's return. And I don't even know how to access PromiseValue.
What is the proper way to make an asynchronous fetch call?
PS: I'm using vanilla JS.