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 ?
You don't see the
request.queryoutput because of the response's schema.The response schema filters out all the fields that are not defined, so the
propertiesfield lists thestatuskey as object without any properties.You should change it to:
or adding the
greetingsproperty.You can read about it here: https://github.com/fastify/fast-json-stringify#additionalProperties