I have a REST service to fetch visitor values. However, I can not manipulate the values coming from the service outside the promise .
export default{
data(){
return{
visitor: {}
}
}
}
created(){
this.VisitorService.show(this.visitorStorage)
.then(visitor => {
this.visitor = visitor;
console.log(this.visitor);
// dentro da promise ok, apresenta o valor.
}).catch(error =>{
console.log(error);
});
console.log(this.visitor);
// fora, imprime somente o objeto
}
Does anyone have any idea what I might be doing wrong?
Printed results within promisse
Resultthatisprintedoutofpromisse