Chapter 9Using REST APIs in Single Page Blogger
Applying $resource
to Our App
Let's return to our Single Page Blogger app and use AngularJS's
$resource
to store all our blog posts on a remote
server. I've developed a RESTful back end to store blog posts using
Node.js and MongoDB. The app has been deployed to OpenShift Cloud and can
be accessed at
http://spblogger-sitepointdemos.rhcloud.com
.
Here is what the API looks like:
URL | HTTP Verb | Request Body | Result |
---|---|---|---|
/api/posts | GET | empty | Returns all posts |
/api/posts | POST | JSON String | Create new post |
/api/posts/:id | GET | empty | Returns single post |
/api/posts/:id | PUT | JSON String | Updates existing post |
/api/posts/:id | DELETE | empty | Deletes existing post |
Note: Making Cross-domain API Calls
Normally you won't be able to make cross-domain ...
Get AngularJS: Novice to Ninja now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.