08.02.2017 Views

vuejs

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Integrating vue-resource 126<br />

43 methods: {<br />

44 createStory: function () {<br />

45 var newStory = {<br />

46 plot: "",<br />

47 upvotes: 0,<br />

48 editing: true<br />

49 };<br />

50 this.stories.push(newStory);<br />

51 },<br />

52 fetchStories: function () {<br />

53 var vm = this;<br />

54 this.$http.get('/api/stories')<br />

55 .then(function(response){<br />

56 // set data on vm<br />

57 var storiesReady = response.data.map(function (story) {<br />

58 story.editing = false;<br />

59 return story<br />

60 })<br />

61 vm.$set('stories', storiesReady)<br />

62 });<br />

63 },<br />

64 }<br />

65 });

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!