0

I read https://github.com/fastify/fastify/blob/master/docs/Routes.md

But my router doesn't seems to catch the right url with params

Url : /app/name?id=666&method=3&_=1553342444710

I tried:

fastify.get('/app/:id-:method:*', (request, reply) => {
fastify.get('/app/*', (request, reply) => {
fastify.get('/app/:id-:method:-:_', (request, reply) => {
Anonymous
  • 69
  • 12
  • `fastify.get('/app/*'` Seems works after all – Anonymous Mar 23 '19 at 15:53
  • `:param` define path parameter, you cant read the query params in the url declaration. so `'/app/*'` will reply for all the route like `app/foo` not only `app/name`. So what is the wanted behaviour? – Manuel Spigolon Mar 25 '19 at 12:35

1 Answers1

1

Try this:

fastify.get('/app/name', {
  schema: {
    querystring: {
      id: { type: 'integer' },
      name: { type: 'string' },
      _: { type: 'integer' },
    }
  },
},
(request, reply) => {
  ...
Fraction
  • 11,668
  • 5
  • 28
  • 48