[Vuejs]-Aixos reponse data can not assign to Vue instance's data

0👍

The callback is on a different scope…this should work

methods: {
    viewBooks: function() {
        let self = this;
        axios.get('/books.json')
            .then(res=>{
                self.bookList = res.data.bookList;
            })
            .catch(error=>{
                console.log(error);
            });
    }

There’s also a different answer here

Leave a comment