[Vuejs]-Axios GET request got error, but I see response in browser

0👍

You can tried something just like this:

<script>
var app = new Vue({
    el: '#app',
    data: {
        comment: ''
    },
    mounted() {
        this.btn_pressed()
    },  
    methods: {
        btn_pressed() {
            axios.get('/')
                .then(res => {
                    this.comment = 'Response is ' + res.data
                })
                .catch(err => {
                    this.comment = 'The error is ' + err
                })
        }
    }
})

Leave a comment