'RTK Query: Specifying error type per endpoint
Is there a way to specify error response per endpoint? Like we can specify Result & Request type when defining a query or mutation. I did went through the documentation and updated the base query. I am getting the generic success/error response types but still trying to figure out how to define error type per endpoint.
Solution 1:[1]
As per our GitHub Discussion (which might be insightful for others with the same question): not at the moment.
Solution 2:[2]
My issue as well is that there is a type definition for {error} and they don't comply to my console.log(error). The following solution allowed me to define my own types for {error}
} else if (error) {
console.log(error);
const newError:CreateYourInterfaceBasedOnConsoleLog = error;
content = <p>{newError.status} = {newError.data.detail}</p>
} else {
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | phry |
Solution 2 | ML Rozendale |