O'Reilly logo

AngularJS: Novice to Ninja by Sandeep Panda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

URLHTTP VerbRequest BodyResult
/api/postsGETemptyReturns all posts
/api/postsPOSTJSON StringCreate new post
/api/posts/:idGETemptyReturns single post
/api/posts/:idPUTJSON StringUpdates existing post
/api/posts/:idDELETEemptyDeletes existing post

Note: Making Cross-domain API Calls

Normally you won't be able to make cross-domain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required