Answers for "node js request json as string"

3

node string to json

const json = '{"result":true, "count":42}';
const obj = JSON.parse(json);
Posted by: Guest on April-08-2021
-1

node js return json

var http = require('http');

var app = http.createServer(function(req,res){
    res.setHeader('Content-Type', 'application/json');
    res.end(JSON.stringify({ a: 1 }));
});
app.listen(3000);

// > {"a":1}
Posted by: Guest on June-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language