Get the Query String from a Netlify Function call

Posted on September 11, 2021

Netlify Functions give already an object with the query parameters passed on a request:

const my =

but if you need to do something else with that string, such as, parse it because you need nested parameters using, for example, the query-string parser, you can do something like:

const qry = event.queryStringParameters

// get back the string from parameters
const queryStr = Object.keys(qry).map(key => `${key}=${qry[key]}`).join('&')

// parse with your lib of choice:
const query = queryString.parse('?' + queryStr)

For the record, I'm using a specific fork (github:wizbii/query-string) of query-string that still supports nested parameters.