How can you send JSON data as a response using the http module in Node.js?

  • response.sendJSON(jsonDat
  • response.write(JSON.stringify(jsonData))
  • response.json(jsonData)
  • response.send(jsonData)
To send JSON data as a response using the http module in Node.js, you should use response.write(JSON.stringify(jsonData)). This method writes the JSON data as a string to the response. The other options are not valid methods for sending JSON data in the http module.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *