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);
});

posted @ 2018-01-21 11:24  pyj063  阅读(725)  评论(0编辑  收藏  举报