andremellow
2 years ago
208
5
Vue

Update Vue object with Axios response data

Posted 2 years ago by andremellow

Hi, need a little help :)

I'm make an ajax request with Axios, and I'm getting a correct response, but currentLog object never changes.

This is vue code

new Vue({
    el: '#app',

    data: {
        logs: {!! json_encode($logs) !!} ,
        currentLog: {}
    } ,

    methods : {
        showDetails : function(log){
            axios.get(`/mail-log/${log.id}`)
              .then(function (response) {

                console.log(response.data);

                this.currentLog = response.data;

                $('#modal-details').modal('show');
              })
              .catch(function (error) {
                console.log(error);
              });
            
        }
    } 

});

this is the response

Object {id: 1, from_name: "Example", from_mail: "[email protected]", subject: "Send Test Mail", body: "<!DOCTYPE html>↵<html>↵↵<head>↵    <meta name="vie…</td>↵        </tr>↵    </table>↵</body>↵</html>↵"…}

Any Idea?

Please sign in or create an account to participate in this conversation.