Integration and REST
In this section we are going to attempt to build a realistic app against a real API.
We have a public restful API that has articles, authors and comments. The endpoint is at:
In order to get a list of all current articles, you would hit: https://simple-api.herokuapp.com/api/v1/articles
To get a specific article, get https://simple-api.herokuapp.com/api/v1/articles/1
To create an article, post a JSON payload to https://simple-api.herokuapp.com/api/v1/articles
The API spec is as follows:
GET /api/v1/articles/:id/destroyPOST /api/v1/articles/:id/updateGET /api/v1/articles/:article_id/commentsGET /api/v1/articlesPOST /api/v1/articlesGET /api/v1/articles/:idGET /api/v1/authors/:id/destroyPOST /api/v1/authors/:id/updateGET /api/v1/authors/:author_id/articlesGET /api/v1/authorsPOST /api/v1/authorsGET /api/v1/authors/:idGET /api/v1/comments/:id/destroyPOST /api/v1/comments/:id/updateGET /api/v1/commentsPOST /api/v1/commentsGET /api/v1/comments/:id
Exercise - integration
We are going to build a little app that can talk to this API. Use the NG-cli to make this easier.
You will need to create a nice little service that can do the AJAX. Pick a resource (probably articles), and make a service that can talk to it.
Now make a component that will inject the service. This will get a list of articles and render them on the page.
For bonus points, allow the user to click on an article and render it on the page.