const got = require('got');
var config = {
url: '/authorization/tokenrequest',
body: data,
// method: 'post',
headers: {
'Content-Type': 'application/json',
}
}
module.exports.hello = async() => {
const response = await got.post(config).then(ok => {
console.log(ok.body);
var parsedJson = JSON.parse(ok.body);
if(parsedJson.Value.Success){
var token = 'Bearer ' + parsedJson.Value.AuthenticationToken;
var data = JSON.stringify({"userid","test"});
var configs = {
method: 'post',
url: '/user/userprofile',
headers: {
'Authorization': 'Bearer oYi1hP9p20LUi8DIERHhITGXEsVNkEweEshN6VMNsssCTBy8iYBxbcH3GJDyNJ9KILejscff5kQrM3V9uTecgaS1cu90xXmcb4L0NiVY4gHvotbazG8ARDZ5vE29bkQhaxaZunqZyb6mwLtGVz3IpYJxAg7hR9zi6x3tWE3Ir56wiFoXnZfgUgYJKdn8FMeC+Yyj6a7B19/MDqTs85rqN1V4RflNEy+tZr2c+lCicMarQdjMLOs2GISEFuouXDRdl4J8cYWRHIE/aVNwkhB5g4sHMlYdO+Lcva6bmowl8WrPUoCOzgxEzV9PzGHmjKY1sgn5HLv85MYySx1Y6XliKZ/lBW9N4L75iwm87rFbjhVJxzSEqRQEt9c6e71fc5fxkv01ITnmdnD57eFkZzLqV2A1NbUBId8qb2dh1rfjq7PD8ohFtMFSOcB4tuHbUx8k8NQn+ws/MW/hItOSnqF2/pj8UR/Sf8txm3ncAHr2GLaoYbfRg++GrVusk/wFhjzmm8jzbJR0acJN01XLxBX7zhO8xzQCKgjXruonnSGF821Vl1F328GvwMLDpwKOTbi/zlPZA2G7d++mkGaiW6hH2/n3TKSXurVcnpAeVEvEaCAvLoMZvucNIAkSuD9mhEOq',
'Content-Type': 'application/json',
},
data : data
};
console.log(configs);
const userResponse = got.post(configs).then(ok => {
console.log(ok.userResponse);
var userResponseJson = JSON.parse(ok.userResponse);
console.log(userResponseJson);
})
.catch(function (error) {
console.log(error);
});
}
}).catch(reject);
}
出现以下错误 HTTPError: Response code 500 (Internal Server Error) at Request.request.once (\node_modules\got\dist\source\as-promise\index.js:117:42) at process._tickCallback (internal/process/ next_tick.js:68:7)
获取令牌然后在节点 js 的另一个端点中使用它的最佳方法。