为什么nodejs中post请求中不能写and userpass='
2个回答
展开全部
调用官方api的时候,有一步需要用post发送请求,于是上网查了些资料,发现一般发送post请求的做法是(下面是简化版代码):
var querystring = require('querystring');
var https = require('https');
var post_data = querystring.stringify({
"name":"BOb",
"age":30,
"job":"teacher"
});
var post_req = https.request(post_opt,function(res){
//some code here
});
post_req.write(post_data);
post_req.end();
然而官方api要求发送的数据是这样的:
{
"action_name": "QR_LIMIT_SCENE",
"action_info": {
"scene": {
"scene_id": 1000
}
}
}
var querystring = require('querystring');
var https = require('https');
var post_data = querystring.stringify({
"name":"BOb",
"age":30,
"job":"teacher"
});
var post_req = https.request(post_opt,function(res){
//some code here
});
post_req.write(post_data);
post_req.end();
然而官方api要求发送的数据是这样的:
{
"action_name": "QR_LIMIT_SCENE",
"action_info": {
"scene": {
"scene_id": 1000
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询