Using core node.js I can handle form-data

var qs = require('querystring');
var body = '';
        req.on('data', function(chunk) {
            body += chunk.toString();
        });
        req.on('end', function() {
             var data = qs.parse(body);
             console.log(data);

        });

But it didn't handle application/json data properly. The output is like that: { '{"user_id":"41","url":"http://localhost:4200/#/ticket/createTicketL': '', 'T"}': '' }

whether the request data is :{user_id: "41", url: "http://localhost:4200/#/ticket/createTicketL&T"}

How to handle the data properly?

0 Answers