Skip to content

How to define route parameters? #73

Answered by RobinTail
vedun asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @vedun ,

Thank you for the question.
The path is being constructed by concatenation of properties defined in Routing object.
So you just need to have an :id property inside of user. In order to do that you need to wrap it in quotes.

To obtain the value of URL param you will also require a middleware that will provide your endpoint handler with such option.

Here is a complete example for you:

const paramsProviderMiddleware = createMiddleware({
  input: z.object({}),
  middleware: async ({request}) => ({
    params: request.params
  })
});

const endpointsFactory = new EndpointsFactory();

const myEndpoint = endpointsFactory
  .addMiddleware(paramsProviderMiddleware)
  .build({
    me…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by RobinTail
Comment options

You must be logged in to vote
0 replies
Comment options

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #31 on July 18, 2021 12:18.