Advertisement
Guest User

http request from the hosted javascript code

a guest
Mar 29th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var http = require('http');
  2.  
  3. exports.run = function ( request, response )
  4. {
  5.     http.get('http://api.backendless.com/', function (res) {
  6.       var body = '';
  7.  
  8.       res.on('data', function (chunk) {
  9.         body += chunk;
  10.       });
  11.      
  12.       res.on('end', function () {
  13.         response.send( body );
  14.       });
  15.  
  16.       res.resume();
  17.     }).on('error', function(err) {
  18.         response.status(500).send(err.message);
  19.     });
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement