I'm using Typescript with RTK mutation everything is working good but if I send any error from backend in specific JSON format like:
{
status: "Error",
message "Something went wrong"
}
When I check on my browser network tab its showing me the correct error response like:
{
data: {
status: "Error",
message "Something went wrong"
}
}
I'm getting error in the mutation hook:
const [createCategory, {isLoading, error }] = useCreateCategoryMutation();
but I can't access error.data.message
in my react it is giving me types error like:
Property 'data' does not exist on type 'FetchBaseQueryError | SerializedError'.