Skip to content

Instantly share code, notes, and snippets.

@sejoker
Created November 22, 2014 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sejoker/20b4d6ea022ad34757c0 to your computer and use it in GitHub Desktop.
Save sejoker/20b4d6ea022ad34757c0 to your computer and use it in GitHub Desktop.
request
  1. npm install request в локальной папке с решениями
  2. сохраните следующий код в отдельном файле get.js:
var request = require('request');

module.exports = function (url, cb){
  request(url, function(error, response, body){
    if (error){
      cb(error);
    } else {
      cb(null, body);
    }
  });
};
  1. подключите get.js в файле с решением:
var get = require('./get');
  1. пример использования:
get(url, function(err, body){
    callback(err, body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment