Response of API is string instead of JSON

I am sending request to a particular API, whose response is JSON. I have a custom node in n8n which sends the request. However, response of the node is string instead of JSON. I always get JSON response in postman. Checking the output of this.helpers.request on console, always gives a string. Also, it was giving JSON response few days back. After the latest update, I am having this issue. What could be the problem?

Hey @krisk918,

Have you tested on an older version of n8n again just to confirm the update could be causing the issue? There was a change to the HTTP library a few versions ago so depending on what version you went from / to it could be that so you may need to rework the code in your node to work with that.

It may be worth just making sure that your node is not using JSON.stringify() or just call JSON.parse() to convert it back to a javascript object.

@krisk918 can you please post the options that you are using to send the request. We can then have a look. Thanks!

Of course, JSON.parse() solved the problem. I was just curious to know why it’s happening. I’ll try with older version and update.

The options I am using :
method : 'POST', body : body_payload, uri : api_endpoint, json : true