我有这段代码:
const { username, password, provider } = this;
login(username, password, provider, (err) => {
this.signingIn = false;
if (err) {
this.hasError = true;
}
const { $route, $router } = this;
let redirect = '/';
if ($route.query.redirect !== undefined) {
redirect = $route.query.redirect;
}
$router.push(redirect);
this.errors = err.response.json();
var a = this.errors;
console.log(a);
//console.log(JSON.stringify(a));
});
当我从导航器中看到控制台时,输出为:
Promise {<resolved>: {…}}
__proto__: Promise[[PromiseStatus]]:"resolved"
[[PromiseValue]]: Objecterrors: Array(1)
0:
code:"validation.required"
detail:"password is required"
where:"request.body.password"__proto__: Objectlength: 1__proto__:
Array(0)__proto__: Object
我刚收到一个Promise对象,我只想从&#39;代码&#39;中获取值。或者&#39;细节&#39;或者&#39;其中&#39;在console.log()
中如果我尝试使用stringify,我只需要两个键{}
你知道一个特殊的方法,或者是获取这个值的方法吗?