Skip to content
Advertisement

Returning [object Promise] instead of actual value

I am new to promises as I am trying to get some objects to show there actual values on a webpage. Instead I am just getting a bunch of [object Promise] instead

This is the code I have so far:

JavaScript

What I tried

I tried reading the firefox promise.resolve method as that seems like what I was looking for: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve However I tried using the static promise.resolve method example they have and it didn’t work for me. Like so:

JavaScript

So I don’t think that is what I am looking for. I also tried reading here: https://stackoverflow.com/a/64165144 but I don’t know how to use the .then method to get the variables from the result. I already put .then in the api request at the first function yet I still have a list of promises.

Picture of the code: enter image description here

Picture of the result: enter image description here

I tried Promise.all() but it errored out and didn’t work so I don’t think that is the issue as well. I double checked my queriedresults variable to make sure its an object by using console.log(typeof queriedresults) and it said it was an object.

Attempted code:

JavaScript

Error: Uncaught (in promise) TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))

Picture of the failure again

enter image description here

I tried using:

JavaScript

based on the information from here: https://stackoverflow.com/a/29516570/16660683 but that didn’t work either as I get an error:

Uncaught (in promise) TypeError: queriedresults.then is not a function

Advertisement

Answer

The proper usage of Promise.all is

JavaScript

Now, getItglinkQuery returns a promise for an array of values, not a promise for an array of promises.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement