问题描述
function parse(){ var options = { 方法:“ POST”, 网址:“ https:// xxxxxxxxxxxxx”, 标头:{'content-type':'application / x-www-form-urlencoded'}, 形式:{ grant_type:“ client_credentials”, client_id:“ xxxxxx”, client_secret:“ xxxxxxxx”, } }; console.log('inside parse'); 返回新的Promise(函数(解决,拒绝){ 请求(选项,功能(错误,响应,正文){ 如果(错误)返回拒绝(错误); 尝试{ console.log('body:'+(body)); resolve((body)); } catch(e){ console.log('error:'+ e); 拒绝(e); } }); }); }
var promise = parse();
promise
.then(function(val) {
var obj = JSON.parse(val);
console.log("val : "+typeof(obj));
global.a = obj.access_token;
console.log('a : '+global.a);
agent.add('yaayyyyyyy');
})。catch((错误)=> {console.log(错误);});
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)