node.js - error that the header can not be reset -
i have main file called server.js in has method in post call request of url
var gotoother = require('./gotoother.js'); app.post ('/gotoother/', function (req, res) { var data = { "error": 1, "zone" "" }; sms.gotoother (req, res, msgsms; });
i have file called gotoother gotoother.js
exports.gotoo
therurl = function (req, res, next, msgsms) { var data = { "error": 1, "sms": "" }; var url = "http://www.google.com.br"; req.redirect ({ uri: url, method: "post" }, function (error, response, body) { console.log (error); //console.log(body); date ["error"] = 0; date ["sms"] = "successfully sent"; res.json (data); next (); }); };
i read texts , did not understand happening , remade several times read between them tried recreate new post method sends calls url continued giving error header can not reset. error this: error: can not set after headers sent.
at serverresponse.outgoingmessage.setheader can't set headers after sent.
in gotoother.js need this: need create other variable creat request. did , worked.
var request = require('request'); exports.enviosms = function (req, res) { var url = "http://www.google.com"; request ({ uri: url, method: "post" }, function (error, response, body) { };
Comments
Post a Comment