Property 'data' does not exist on type 'Promise<{...
I am very new to react query, I think my solution is very simple and im being stupid.. But I cant figure it out.
export async function useFetchAccessToken() {
const { data, isSuccess, isLoading, isError } = useQuery({
queryKey: ["accessToken"],
queryFn: async () =>
await axios.get('${endpoint}${URL.accessToken}', {
withCredentials: true,
}),
});
return { data, isSuccess, isLoading, isError };
}
const { data, isSuccess, isLoading, isError } = useFetchAccessToken();
And this is the error - Property 'data' does not exist on type 'Promise<{ data: AxiosResponse<any, any> | undefined; isSuccess: boolean; isLoading: boolean; isError: boolean; }>'.ts(2339)
Sorry if its a very simple and basic solution..2 Replies
correct-apricotā¢3y ago
Remove the async in line 1
stormy-goldOPā¢3y ago
I just noticed.. I am so stupid. Thank you so much haha!
š