var util = require('util'); var Vue = require('vue'), VueMaterial = require('vue-material'), VueResource = require('vue-resource'); var Light = require('../views/light.vue'); Vue.use(VueMaterial); Vue.use(VueResource); var App = new Vue({ el: '#app', http: { root: '/api', }, components: { lightItem: Light }, data: { lights: [], selectedLight: {} }, methods: { toggleSidenav: function () { this.$refs.leftSidenav.toggle(); }, sidenavOpen: function () { console.log('sidenav open'); }, selectLight: function (light) { this.$data.selectedLight = light; this.$refs.leftSidenav.close(); } }, mounted: function () { console.log('mounted'); var that = this; this.$http.get('lights', { responseType: 'text' }).then(function (result) { console.log('result', result); that.$data.lights = result.body.lights; that.$data.selectedLight = result.body.lights[3]; }, function (error) { console.log('error', error); }); } });