Reading the client’s input
Every API must read the client’s input to behave. We already mentioned the four HTTP request input types, which are supported by Fastify:
- The path parameters are positional data, based on the endpoint’s URL format
- The query string is an additional part of the URL the client adds to provide variable data
- The headers are additional
key:value
pairs that pair information passing between the client and the server - The body is the request payload that contains the client’s data submission
Let’s take a look at each in more detail.
The path parameters
The path parameters are variable pieces of a URL that could identify a resource in our application server. We already covered this aspect in Chapter 1, so we will not repeat ourselves. Instead, it will be interesting to show you a new useful example that we haven’t yet covered; this example sets two (or more) path parameters:
app.get(&apos...