here is what i get in browser console and the code. I need first promise "starships" to get an array of url links, then i need second promise for "movieURLs" to get an object from each of that link. But when i finish it all i always get a Promise object with a pure object inside it and i need that object to access it and cannot when its in that form.
Im doing it in React.
this is what i get in console:
(3) [Promise, Promise, Promise]
0
: Promise
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: Object
id
: 4
releaseDate
: "1977-05-25"
title
: "A New Hope"
[[Prototype]]: Object
1
: Promise
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: Object
id
: 6
releaseDate
: "1983-05-25"
title
: "Return of the Jedi"
[[Prototype]]: Object
2
: Promise {<fulfilled>: {…}}
length
: 3
[[Prototype]]: Array(0)
My code:
PromiseAll([getStarships(user)])
.then((result) => result[0][starshipIndex].films)
.then((movieUrls) =>
movieUrls.map((movieUrl: any) =>
getMovies(movieUrl).then((data) => data[0]),
),
)
.then((movieList) => setMovies(movieList))
.catch((error) => console.warn(error))
I tried to use .result or .response or .response.items, but i always get undefined