Advertisement
Guest User

Untitled

a guest
Jan 29th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. var _request = require('request'); // https://www.npmjs.com/package/request
  2. var _express = require('express'); // https://www.npmjs.com/package/express
  3. var _app = new _express();
  4.  
  5. # binding routes to your app
  6. _app.post('/auth', function(request, response){
  7. _request.post(
  8. '/api/auth', // URL
  9. { username: 'John', password: '######'},
  10. , function(error, httpResponse, body){
  11. if(err){
  12. res.json("Error.");
  13. }
  14.  
  15. // 'body' is the response of your API Request
  16. }
  17. );
  18.  
  19. // OR GET Request
  20.  
  21. _request.get(
  22. '/api/data', // URL
  23. , function(error, httpResponse, body){
  24. if(err){
  25. res.json("Error.");
  26. }
  27.  
  28. // 'body' is the response of your API Request
  29. }
  30. );
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement