Friday, 5 May 2017

javascript Access variable outside of promise

I need to access the variable returned by the promise outside of the then, in the example above, console.log(json.nome) outside of then returns undefined, and I need to access this value outside.

var json = {};
e[i].element(by.css(".nome_projeto")).getText().then(function(text){
    json.nome = text;
    console.log(json.nome);
});
console.log(json.nome);



via Rogger Fernandes

No comments:

Post a Comment