Khubaib
Khubaib

Reputation: 103

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.

Upvotes: 3

Views: 6937

Answers (2)

ML Rozendale
ML Rozendale

Reputation: 193

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 {

Upvotes: 0

phry
phry

Reputation: 44226

As per our GitHub Discussion (which might be insightful for others with the same question): not at the moment.

Upvotes: 1

Related Questions