node中js页面发送request请求
注意:使用promise回调函数
var that = this;
new Promise((resolve, reject) => {
console.log('进入Promise方法了');
request({
method: 'GET',
url: wx_gettoken_url
}, function(err, res, body) {
if (res) {
resolve({
isSuccess: true,
data: JSON.parse(body)
});
} else {
console.log (err);
reject({
isSuccess: false,
data: err
});
}
})
}).then(proData => {
that.getQrcode(proData);
});