T
TanStack2y ago
absent-sapphire

in useMutation, how to get error status code inside onError?

const {
data: getPricingData,
isPending,
mutate,
} = useMutation({
mutationKey: ['get-pricing'],
mutationFn: () => fetchPricing(),
onError: (error) => {
console.log(error);
},
});
const {
data: getPricingData,
isPending,
mutate,
} = useMutation({
mutationKey: ['get-pricing'],
mutationFn: () => fetchPricing(),
onError: (error) => {
console.log(error);
},
});
I want to access the error status code.
1 Reply
correct-apricot
correct-apricot2y ago
should fetchPrincing throw the error?

Did you find this page helpful?