MeanJS - Expose data as JSON via API

One of my objectives with migrating data out of Drupal and into a MEAN stack app is for easier management of downstream requests for JSON data. We want to take advantage of the built in functionality of the MeanJS stack, and here's a simple exaple.

In this use case we wish to expose articles to some other app who will make a HTTP GET request for all the articles or just one.

In app/controllers/articles.server.routes.js, we need to add entries for the two functions we'll allow via GET.

Save this change and use the URL localhost:3000/api/articles or localhost:3000/aticles/<your article _id here>.
[{"_id":"553940bcbfadec1124c93082","user":{"_id":"553818ad7e5443733ddda340","displayName":"Peter McMillan"},"__v":0,"content":"article 1","title":"article 1","created":"2015-04-23T18:58:04.321Z"}]


Add new comment

By submitting this form, you accept the Mollom privacy policy.