`import querystring from "querystring"` translating entire `body` as single Object key

in netlify function:

import querystring from "querystring";


  const params = querystring.parse(event.body);

but params logs as:

  [Object: null prototype] { '{\n\t"name": "Jane"\n}': '' }

Why is my entire body getting created as the key to this object?

Hi @JamesWholebear, That’s because you’re passing the body of the inbound request in to your querystring parser. You don’t actually need to manually parse the query params since they are available in an object on the event as event. queryStringParameters already.

Thanks for responding @futuregerald, I don’t seem to be able to do this on a POST request. I just get

[Object: null prototype] {}

I’m not sure what you’re printing there but it works for me in my tests:


And that’s using the following code in the function:

exports.handler = function (event, context, callback) {

    console.log(`This is the value of test: ${event.queryStringParameters.test}`);

    callback(null, {
        statusCode: 200,
        body: JSON.stringify(event)