0

I have this code:

      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));
  });

when I see the console from the navigator, the Output is:

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

I just receive a Promise Object, I just want get the value from 'code' or 'detail' or 'where' in a console.log()

If I try with stringify I just get two keys {}

Do you know a special method or, which is the way to get this values??

FranzSif
  • 113
  • 2
  • 11
  • Clearly, the return value of `err.response.json()` is a Promise. So you have to consume the promise. See the linked question and [MDN's documentation on promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). – T.J. Crowder Jun 15 '18 at 15:51
  • Thank you @T.J Crowder the promise was not solved, because give this message, I try use then to solve the promise and voalá, the next result was a array, tk a.then((res) => { console.log(res) }) – FranzSif Jun 15 '18 at 16:31

0 Answers0