Skip to content

Instantly share code, notes, and snippets.

@nabanita-sarkar
Last active February 2, 2022 16:57
Show Gist options
  • Save nabanita-sarkar/1eb10a3d9010d95fe6360bc0f7446f38 to your computer and use it in GitHub Desktop.
Save nabanita-sarkar/1eb10a3d9010d95fe6360bc0f7446f38 to your computer and use it in GitHub Desktop.
const { isLoading, isError, data } = useQuery(
["todo/detail", id],
() => {
return axios.get(`http://localhost:4000/todo/detail/:${id}`);
},
{
enabled: !!id,
retry: 1,
onSuccess: () => {
// invalidate some query
},
onError: () => {
// do something else
},
}
);
const fetchedTodo = data.data.todo
const fetchTodoStatus = data.status
export { isLoading, isError, fetchedTodo, fetchTodoStatus }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment