[Vuejs]-How to Retrieve Image from server using Vue Js?

0👍

Looking at the code you have posted, the showImage() method is not within the methods object of the Vue instance. Try putting the method into the methods object and see if that makes a difference.

data: function() {
    return {
        image: "",
        posts: [],
    };
},
methods: {
    showImage() {
        axios.get("test").then(function(response) {
                $test = this.posts = response.data.posts;
                console.log($test);
            }).catch(function(error) {
                console.log(error);
            });
    }
}

Leave a comment