在Node.JS上使用请求模块发布数据 [英] POST data with request module on Node.JS
本文介绍了在Node.JS上使用请求模块发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此模块为'request https://github.com/mikeal/request
This module is 'request https://github.com/mikeal/request
我认为我正在遵循每个步骤,但是我错过了一个论点.
I think i'm following every step but i'm missing an argument..
var request = require('request');
request.post({
url: 'http://localhost/test2.php',
body: "mes=heydude"
}, function(error, response, body){
console.log(body);
});
我的另一端
echo $_POST['mes'];
我知道php没错...
And i know the php isn't wrong...
推荐答案
You should check out Needle. It does this for you and supports multipart data, and a lot more.
我发现我缺少标题
var request = require('request');
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://localhost/test2.php',
body: "mes=heydude"
}, function(error, response, body){
console.log(body);
});
这篇关于在Node.JS上使用请求模块发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文