const request = require('request');
const async = require('async');
var token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpcCI6IjEyMy41Ni4yMzIuMTA2IiwianRpIjoiaVoyemU2OGZoNXhrN3A2dHV1ZG5jbVovMC85NDQzLzE0NjEyLzE1MzI5Mjg2MTkxMDQvMSIsInNjaG9vbCI6NSwiaWF0IjoxNTMyOTI4OTExLCJzdWIiOjF9.tsPzRGaP4N241Dk0CFp8z4Y3lTg-LnOp_ZPPABsUdEw'
var options = {
url: `xxxxx`,
json: true,
method: "GET",
rejectUnauthorized: false,
headers: {
Authorization: "Bearer " + token
}
};
var fun = function(){
async.auto({
get_1: function(callback) {
request(options, function (err, res, body) {
if (err) {
console.log(err);
} else {
console.log(1);
//console.log(body);
}
callback(err, body);
});
},
get_2: function(callback) {
request(options, function (err, res, body) {
if (err) {
console.log(err);
} else {
console.log(2);
//console.log(body);
}
callback(err, body);
});
}
});
};
fun();
如果网站需要令牌,则会出现问题:看这张图片:
但是,如果网站不需要令牌,则可以正常运行; 并且我使用了不同的令牌,但是仍然存在这个问题。