Skip to content

Is it possible to use zodios to change the response type with Query parameter by parameter? #448

Answered by ecyrbe
soshiharami asked this question in Q&A
Discussion options

You must be logged in to vote

Use zod discriminated unions or just unions.
And do a runtime check.
Else you can do this :

export const endPoints = makeApi([
  {
    method: "get",
    path: "/v1/test?id=A",
    requestFormat: "json",
    response: TypeA ,
  },
{
    method: "get",
    path: "/v1/test?id=B",
    requestFormat: "json",
    response: TypeB
  },
]);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@soshiharami
Comment options

Answer selected by soshiharami
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants