我有代码:
var client = new Client();
var args = {
data: {
"filters": {
"uuid": "11111",
"period": "2018-03-18T00:00:00-05:00/2018-03-21T00:00:00-05:00"
}
},
headers: {
"Content-Type": "application/json",
"Api-User": "myusername",
"Api-Key": "myapikey"
}
};
client.post("https://myAPIenpoint/", args, function (data, response) {
values = JSON.parse(JSON.stringify(data)).id;
console.log(values);
});
console.log(values);
第一个控制台日志返回正确的值,但第二个返回 ReferenceError: values is not defined
如何在 client.post 之外获取值?我知道我可能遗漏了一些简单的东西?