25
rated 0 times
[
32]
[
7]
/ answers: 1 / hits: 6956
/ 2 Years ago, thu, october 13, 2022, 12:00:00
when I console data for the first console.log, it's given me undefined.
somethings likes:
log: undefined
but if I trying to again try to save the file using Ctrl s ,it's working fine and give me values for the API.
here is my code below:
const fetchPosts = () => {
const fP = devices?.map(async (id) => {
const { data } = await axios.get(`https://jsonplaceholder.typicode.com/users`, myHeaders);
return [data?.data.id];
})
return fP;
};
const { data } = useQuery('post', fetchPosts);
console.log(data);
how can i avoid undefined for the first console.log?
anyone can help me to solve this issues.
Thankyou for your trying in advance!
More From » react-native