Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
request.query does not print the query in Fastify (querystring)

I searched for ages, but it just wouldn't print the query, I've no idea what I should do. I'm also kind of new to Fastify. Also I'm sending the request to 127.0.0.1/?greeting=something.

const opts = {
  schema: {
    querystring: {
      type: 'object',
      required: ['greeting'],
      properties: {
        greeting: {type: 'string'},
      },
    },

    response: {
      200: {
        type: 'object',
        properties: {
          status: {type: 'object'}, // i've abosulutely no idea what the type should be
        },
      },
    },
  },

  handler: async (request, reply) => {
    reply.send({
      status: request.query,
    })
  }
}

Can someone please help me in resolving this ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You don't see the request.query output because of the response's schema.

The response schema filters out all the fields that are not defined, so the properties field lists the status key as object without any properties.

You should change it to:

status: { type: 'object', additionalProperties: true }

or adding the greetings property.

You can read about it here: https://github.com/fastify/fast-json-stringify#additionalProperties

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda