08.02.2017 Views

vuejs

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Integrating vue-resource 127<br />

10.6 Homework<br />

To get comfortable with making web requests and handling responses you should replicate what we<br />

did in this chapter.<br />

What you have to do is to consume an API in order to:<br />

• create a table and display existing movies<br />

• modify existing movies<br />

• store new movies in the database<br />

• delete movies from the database<br />

I have prepared the database and the API for you. You only have to write HTML and JavaScript.<br />

10.6.1 Preface<br />

If you have followed the instructions from Chapter 8 open your terminal and run:<br />

cd ~/themajestyof<strong>vuejs</strong>/apis/movies<br />

sh setup.sh<br />

If you haven’t, you should run this:<br />

mkdir ~/themajestyof<strong>vuejs</strong><br />

cd ~/themajestyof<strong>vuejs</strong><br />

git clone https://github.com/hootlex/the-majesty-of-<strong>vuejs</strong> .<br />

cd ~/themajestyof<strong>vuejs</strong>/apis/movies<br />

sh setup.sh<br />

You now have a database filled with great movies along with a fully functional server running<br />

on ‘http://localhost:3000’!<br />

To ensure that everything is working fine browse to ‘http://localhost:3000/api/movies’ and you<br />

should see an array of movies in JSON format.<br />

10.6.2 API Endpoints<br />

The API Endpoints you are going to need are:

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

Saved successfully!

Ooh no, something went wrong!