0
I am consuming an api in nodejs but I cannot pass the parameters req.body is becoming empty and I cannot identify the problem
var express = require('express') var app = express() var bodyParser = require('body-parser') var core_use = require('cors'); var sql = require("mssql");
app.use(core_use()); app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ Extended: true }));
var return = { method: ', Uri: ' sponse: [] };
app.get('/query sql.connect(config, Function (err) { var request = new sql.Request(); console.log(req.body); // query to the database and get the Records '' request.query('select * from clients', Function (err, Response) { if (err) { sql.close(); console.log(err); }; return.method = 'GET'; return.Uri = 'query return.Sponse = Sponse.recordsets;
res.setHeader('Access-Control-Allow-Origin', '*');
res.json(retorno);
sql.close();
});
});