[Vuejs]-This is not defined in mounted()

0👍

your code should be like this, create alias for this keyword, withing api.get you may loose this scope.

mounted () {
        var api = fermata.json("/api/books");
        var _this = this;
        api.get(function(err, res) {
            if(res.success) {
                _this.books = res.result;
            }
        });
    }

Leave a comment