Open frankcollins3 opened 1 year ago
export default async function CentralQuery () {
let obj = {
allAPIpokemon: http://localhost:5000/pokemon?query={allAPIpokemon{name,poke_id}}
,
allDBpokemon: http://localhost:5000/pokemon?query={allDBpokemon{name,poke_id,type,moves,abilities,image}}
,
allDataAllPokemon: async () => {
let predata_allAPI = await fetch(http://localhost:5000/pokemon?query={allAPIpokemon{name,poke_id}}
)
let predata = await predata_allAPI.json()
let allAPI = predata.data.allAPIpokemon
return allAPI.forEach(async(pokemon) => {
let predata_allDataAllPoke = await fetch(`http://localhost:5000/pokemon?query={allDataAllPokemon(name:"${pokemon.name}"){name,poke_id,type,moves,abilities,image}}`)
// let predata_allDataAllPoke = await fetch(`http://localhost:5000/pokemon?query={allDataAllPokemon(name:${pokemon.name}){name,poke_id}}`)
let allDataAllPoke = await predata_allDataAllPoke.json()
return allDataAllpoke
console.log(allDataAllPoke)
})
}
}
return obj
}
[3:44am]
let predata_allAPI = await fetch(
http://localhost:5000/pokemon?query={allAPIpokemon{name,poke_id}}
)if this project was bootstrapped with typescript I would consider creating a /Contexts/
having a typesafe, exportable, Read-Only, Explicitly Defined as String values created from createContext()
first proposed approach: make an object with endpoints that are specific queries likely to be reused.