Bonjour,
Voila je rencontre un petit problème avec mon code.
Voilà j'ai une erreur avec mon code, l'erreur est Uncaught (in promise) TypeError: nots.body.forEach is not a function
Voici mon code:
export default {
mounted() {
this.get_unread()
},
methods: {
get_unread() {
this.$http.get('/get_unread')
.then( (nots) => {
nots.body.forEach((not) => {
this.$store.commit('add_not', not)
})
})
}
},
computed: {
all_nots_count() {
return this.$store.getters.all_nots_count
}
}
}
Je vous remercie.
Salut,
L'erreur est pourtant explicite : l'objet nots
n'a pas de méthode forEach
, ce qui signifie que ce n'est pas un array JavaScript valide.
Fais un console.log(nots)
pour voir de quoi il en retourne :
this.$http
.get('/get_unread')
.then(console.log)