requestify icon indicating copy to clipboard operation
requestify copied to clipboard

Can't send form-urlencoded

Open orekav opened this issue 8 years ago • 1 comments

Here I put TWO codes, the first WORKS perfectly (it's correct when it says "captcha_error"... it is INCORRECT when it says " "error" ")

FIRST: var http = require("http"); app.get('/obtenerCPA', (req, res) =>{ var options = { host: 'www.correoargentino.com.ar', path: '/sites/all/modules/custom/ca_forms_mobile/api/wsFacade.php', port: '80', method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'} }; var data = 'action=cpa&localidad=5001&calle=Corro&altura=122&provincia=C&g_recaptcha_response='';

var post_req = http.request(options, (response) => {
	response.setEncoding('utf8');
	response.on('data', function (chunk) {
		res.send(chunk);
  	});
});
post_req.write(data);
post_req.end();

});

SECOND: app.get('/obtenerCPA2', (req, res) =>{ var data = 'action=cpa&localidad=5001&calle=Corro&altura=122&provincia=C&g_recaptcha_response='';

requestify.request('http://www.correoargentino.com.ar/sites/all/modules/custom/ca_forms_mobile/api/wsFacade.php',{
	method: 'POST',
	headers: {'Content-Type': 'application/x-www-form-urlencoded'},
	dataType: 'form-url-encoded',
	body: data
})
.then((response) => {
	console.log('Code Status:\t' + JSON.stringify(response.getCode()));
	res.send(response.getBody());
}),
(error) => {
	res.send(getCode());
}

});

orekav avatar Mar 15 '17 03:03 orekav

Is this ever going to be addressed? I'm pretty sure requestify is deprecated. I moved over to axios instead for my HTTP requests that require form-urlencoded.

eristow avatar Jul 18 '18 14:07 eristow