1
I have a REST service to seek the visitor’s values. However, I cannot 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?
Result printed inside the promise
Result that is printed outside the promise
You can show what is being presented in each case?
– Jéf Bueno
@LINQ Includes two images with the outputs
– Eduardo Bennertz
That one
created
is outside the object, should be after thedata()
. I think that’s just the problem with your code. What’s thatthis.VisitorService
? how you’re adding it to the Vue object?– Sergio