app.post('/geterweima',function(req,res,next){
var postData = querystring.stringify({
"path":req.body.path,
"width":"430"
});
var options = {
hostname:'api.weixin.qq.com',
port:443,
path:'/cgi-bin/wxaapp/createwxaqrcode?access_token='+ token,
method:'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData)
}
}
var r = http.request(options, (s) => {
console.log(s);
s.on('data', (chunk) => {
console.log(chunk);
});
s.on('end', () => {
console.log('响应中已无数据。');
});
});
r.on('error', (e) => {
console.log(e)
});
r.write(postData);
r.end();
})
502 是服务端错误,一般是请求太多了处理不过来,你过一段时间再试试看。