3

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.

Md. Fazlul Hoque
  • 15,806
  • 5
  • 12
  • 32
Khubaib
  • 103
  • 4
  • 12

2 Answers2

1

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

phry
  • 35,762
  • 5
  • 67
  • 81
  • thanks a lot for the detailed reply on github. – Khubaib Oct 14 '21 at 06:01
  • @phry can we specify an error type for all APIs in one place? – tarek noaman Nov 23 '22 at 15:48
  • That error will depend on the `baseQuery` you use - if it's a `fetchBaseQuery`, it will be an according fetch-typed error. By the way: you should probably only have one API in your application, not multiple! – phry Nov 23 '22 at 16:50
0

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 {
ML Rozendale
  • 135
  • 1
  • 1
  • 7