4
I need to push() the data
of Vuejs and make it add another object in the object array it has there. But when I click on the button I programmed for you to push() it just doesn’t.
Follows code:
atualizar () {
axios({
method: 'get',
url: '/server/inbox'
}).then(function (response) {
console.log(response.data)
for (let e = 0; e < response.data.length; e++) {
this.emails.push(
{
remetente: response.data.remetente,
destinatario: response.data.destinatario,
assunto: response.data.assunto,
texto: response.data.texto
},
console.log('PUSH!')
)
}
})
.catch(function (err) {
console.log(err)
})
console.log('Fim!')
}
HTML:
<q-list no-border link inset-separator>
<q-item v-for="email in emails" :key="email.id">
<q-item-side icon="email"/>
<q-item-main>
<q-item-tile :label="emails.remetente">{{ email.remetente }}</q-item-tile>
<q-item-tile :sublabel="emails.assunto">{{ email.assunto }}</q-item-tile>
</q-item-main>
</q-item>
</q-list>
You’re right that way??
This is the method I created to push the object array, and I’ve already checked the data coming from the server and it’s all right, it’s coming back in the right way.
If anyone can help me I’d appreciate it...
Are you sure that
this
is what you think it is? Test use Arrow functions like this:}).then((response) => {
– Sergio
I tried to put Arrow Function, but it gave syntax error, what would be the right place to put it?? Feel free to edit the question code, or add an answer, I’ll be happy to accept the answer if it helps...
– LeonardoEbert
The best way to thank you is to accept one of the answers as a solution and vote for all that helped you. :)
– user28595
That’s exactly what I did... if I gave it to you I’d take both, but you can only take one, so...
– LeonardoEbert