Nodejs Baas Update/Delete

Hi guys, I am working on Nodejs to communicate with BaaS. I have been following this doc. It mentions about GET and POST operations. I would also like to do PUT and DELETE operations.

I have an idea about how to proceed but if there is any reference doc/github regarding that would be great..

Solved Solved
0 4 351
2 ACCEPTED SOLUTIONS

@Barahalikar Siddharth ,

It should be simple & straight forward, For more reference check express documentation on routes,

app.put('/profile', function(req, res) {
     // Your logic here when a PUT request is made to /profile end point
});

app.delete('/profile', function(req, res) {
     // Your logic here when a DELETE request is made to /profile end point
});

View solution in original post

Hi @Barahalikar Siddharth,

Q; Are you looking for information on how to write put / delete routes in nodejs, i.e. using the http module or the express module?

A; In this case @Anil Sagar's answer above is what you should be looking at.


Q: Or are you looking at information on how to prepare put / delete requests to baas?

A: Construct the URL so that it points to the actual entity, by using the entity UUID or entity name at the end.

Eg:

http://api.usergrid.com/user/org/collection/entity_name

or

http://api.usergrid.com/user/org/collection/uuid

In case of PUT calls, send in the new payload / JSON that has to be updated into the specified entity.

In case of DELETE calls, don't send in anything.

Q: Or are you looking at information on how to actually send the http request from node to BaaS?

A: Please use the request module of node.js to send the correct http requests to BaaS.

Eg: to delete an entity from BaaS.

const request = require('request');
var options = {  
  uri: 'http://api.usergrid.com/user/org/collection/entity_name',
  method: 'DELETE',
};

request(options, function (err, resp, body) {
  // handle the response from the request
});

View solution in original post

4 REPLIES 4

@Barahalikar Siddharth ,

It should be simple & straight forward, For more reference check express documentation on routes,

app.put('/profile', function(req, res) {
     // Your logic here when a PUT request is made to /profile end point
});

app.delete('/profile', function(req, res) {
     // Your logic here when a DELETE request is made to /profile end point
});

Hi @Barahalikar Siddharth,

Q; Are you looking for information on how to write put / delete routes in nodejs, i.e. using the http module or the express module?

A; In this case @Anil Sagar's answer above is what you should be looking at.


Q: Or are you looking at information on how to prepare put / delete requests to baas?

A: Construct the URL so that it points to the actual entity, by using the entity UUID or entity name at the end.

Eg:

http://api.usergrid.com/user/org/collection/entity_name

or

http://api.usergrid.com/user/org/collection/uuid

In case of PUT calls, send in the new payload / JSON that has to be updated into the specified entity.

In case of DELETE calls, don't send in anything.

Q: Or are you looking at information on how to actually send the http request from node to BaaS?

A: Please use the request module of node.js to send the correct http requests to BaaS.

Eg: to delete an entity from BaaS.

const request = require('request');
var options = {  
  uri: 'http://api.usergrid.com/user/org/collection/entity_name',
  method: 'DELETE',
};

request(options, function (err, resp, body) {
  // handle the response from the request
});

Hi @prashant thanks for the info. I have solved this by means of github.

If possible kindly help me with this question,

https://community.apigee.com/questions/27034/usergrid-nodejs-issue-with-createentity-and-getone.html

Not applicable

this blog providing good information To learn NodeJS visit http://iwebworld.info contact: iwebworldinfo@gmail.com