Our backend returns something like this for success:
{
message: "Entry Succesfully Entered",
errorCode: 0,
data: {
success: true,
},
info: [],
});
}
And something like this for failure:
{
info: [],
message: "Some info about the error",
errorCode:
}
The actual error code in the failure response is basically meaningless.
I've got my mutation transforming the response thusly:
transformResponse: ({ data, errorCode, message }) => {
if (data?.success) return { success: true };
return {
error: {
status: errorCode,
message,
},
};
},
However this is always delivered in the data
member of the result returned by the RTKQ hook.
Is there a way to affect the error
(and possibly the isError
) part of that returned result?