Hi, I have an array of objects with ids, i need to get all users data based on ids, i written like below, but i am getting only last id 124 related data. i am unable to get ids 121,122 and 123 data. can any one please help me on how to call an api multiple times with different ids and how to store that all data in local react state
const USER_DATA=gql`
query User($id:String){
User(id:$id){
id
name
email
phone
}}`
const myIds = [
{id:'121',name:"Kiran"},
{id:'122',name:"Joshi"},
{id:'123',name:"Raju"},
{id:'124',name:"Ravi"},
];
function App(){
const [fetchUser, {loading, data, error}] = useLazyQuery(USER_DATA)
useEffect(() => {
myIds.map(async(item)=>await fetchUser({
variables: {
id:item.id
}
}))
}, []);
useEffect(()=>{
console.log(data,'users data...')
},[data])
}