res.json() do in Express?res.json() sends a JSON response to the client. It converts a JavaScript object or array into JSON format and sets the correct headers automatically.
{ message: 'Hello' } using res.json()?Use res.json({ message: 'Hello' }). This sends the JSON { "message": "Hello" } to the client.
res.json() set automatically?It sets Content-Type: application/json so the client knows the response is JSON.
res.json() send arrays as well as objects?Yes! You can send arrays like res.json([1, 2, 3]) and Express will convert it to JSON format.
res.json()?Express will throw an error because it cannot convert functions or undefined values to JSON.
res.json() do in Express?res.json() sends JSON data as a response to the client.
res.json() set automatically?It sets Content-Type: application/json so the client knows the response is JSON.
{ success: true } in Express?res.json() is the correct method to send JSON responses.
res.json() send an array as a response?res.json() can send arrays or objects as JSON.
res.json()?Functions cannot be converted to JSON, so Express throws an error.
res.json() works in Express and why it is useful.res.json() in a web app.