How to make Restful API in Meteor

Hello

I need Help How to make restful API inside Meteor. I have one login screen and one registration screen. that register screen data is saved safely but i need one API that API i want to used in my Native Android APP.

Thanks

Take a look for https://github.com/meteorhacks/picker

Here simple example:
/server/routes.js

import {check} from 'meteor/check';
import {SomeCollection} from '/lib/collections/SomeCollection';

Picker.route('/api/somepath/:id', function(params, req, res, next) {
  check(params._id, String);
  
  const someObject = SomeCollection.findOne({_id: params._id});

  res.setHeader('Content-Type', 'application/json');

  const text = JSON.stringify({
    anObject: someObject.somekey,
    wholeObject: someObject
  });
  res.end(text);
});

res is an instance of NodeJS http.ServerResponse

2 Likes

Thanks For giving reply but I am not clear give me some example with full small project. Its Like login and registration.

You could also try https://github.com/kahmali/meteor-restivus.

1 Like

There is also: simple:rest built by MDG core devs
it is recommended in the Meteor Guide (http://guide.meteor.com)

2 Likes