I know that React query calls the api with useQuery to turn the data into a map and display it on the screen.
export const getList = async() => {
const response = await api.get(/~/~/~/list);
return response.data;
};
export const getNewList = async() => {
const response = await api.get(/~/~/~/Newlist);
return response.data;
};
If there are two things to import, how should I use useQuery on the page? I’m Korean and I’m sorry if the translation is strange, the api was specified by the backend We are making a practice project I called useQuery
twice const { isLoading, isError, data } = useQuery()
Called twice in this way, it turned out that block scope variables could not be declared again.
2
Answers
you can write it simply like this
then you can use the variables from it
would be great if you could provide an example code snipped in codebox, so it is easier to see exact problem. If i understand correctly, your problem is that you cannot use same variable name twice, so what you can do is destruct the response and rename it.