September 2014
Intermediate to advanced
256 pages
5h 25m
English
In the previous chapter, you built a fully functioning Angular app for posting status updates. In this chapter, you will build an API for it to get a list of all the posts and to make a new post. The endpoints will be as follows:
• GET /api/posts returns a JSON array of all the posts. This is similar to what you had in $scope.posts.
• POST /api/posts expects a JSON document containing a username and post body. It will save that post in MongoDB.
To start, you’ll use Node.js and Express to build a stock /api/posts endpoint. First, inside a new folder, create a package.json file like the following:
{ "name": "socialapp"}
The name can be anything you want, but try to ensure it doesn’t conflict ...