const check = async () => {
new Promise( (resolve, reject) => {
fetch(`http://localhost:5000/pokemon?query={puppeteer}`)
.then(async(data) => {
console.log('data in the promise');
**data = await data.json()**
data ?
resolve(
console.log('data'),
console.log(data)
)
:
reject("ben and jerry")
})
})
}
without the await data.json() , the promise returns a promise that hasn't been fulfilled:
if the await keyword precedes the data.json(), and the scope to which that code belongs is an async function,
the data from the GraphQL route is returned successfully:
![Screen Shot 2023-05-13 at 4 08 05 PM](https://github.com/frankcollins3/PHPokedex/assets/73137934/0f505d86-f70c-41f9-86da-4079b7e8bee5)
![Screen Shot 2023-05-13 at 4 07 57 PM](https://github.com/frankcollins3/PHPokedex/assets/73137934/d66ab7f6-25ed-489e-a790-2dc8131cfeec)
The problem is that I thought that Promise solves for the awaited data not populating the values before sequential steps are executed.
**first proposed approach:**
Promise.all?()
or leave this how is it is now with the await keyword
without the await data.json() , the promise returns a promise that hasn't been fulfilled:
if the await keyword precedes the data.json(), and the scope to which that code belongs is an async function, the data from the GraphQL route is returned successfully: ![Screen Shot 2023-05-13 at 4 08 05 PM](https://github.com/frankcollins3/PHPokedex/assets/73137934/0f505d86-f70c-41f9-86da-4079b7e8bee5) ![Screen Shot 2023-05-13 at 4 07 57 PM](https://github.com/frankcollins3/PHPokedex/assets/73137934/d66ab7f6-25ed-489e-a790-2dc8131cfeec) The problem is that I thought that Promise solves for the awaited data not populating the values before sequential steps are executed. **first proposed approach:** Promise.all?() or leave this how is it is now with the await keyword