vuejs
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
9. Working with real data<br />
It is time to actually put to use our database and perform the operations we have mentioned (CRUD).<br />
We will utilize the last example from the Components chapter, but this time of course our data will be<br />
coming from an external source. To exchange data with the server we need to perform asynchronous<br />
HTTP (Ajax) requests.<br />
Info<br />
AJAX is a technique that allows web pages to be updated asynchronously by exchanging<br />
small amounts of data with the server behind the scenes.<br />
9.1 Get Data Asynchronous<br />
Take a moment to have a look at the last example from the Components chapter. As you can see we<br />
hardcode stories array inside the data object of Vue instance.<br />
Stories array hardcoded<br />
1 new Vue({<br />
2 data: {<br />
3 stories: [<br />
4 {<br />
5 plot: 'My horse is amazing.',<br />
6 writer: 'Mr. Weebl',<br />
7 },<br />
8 {<br />
9 plot: 'Narwhals invented Shish Kebab.',<br />
10 writer: 'Mr. Weebl',<br />
11 },<br />
12 ...<br />
13 ]<br />
14 }<br />
15 })<br />
This time, we want to fetch the existing stories from the server.<br />
98