How to use the needle.get function in needle

To help you get started, we’ve selected a few needle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leanote / desktop-app / node_modules / api.js View on Github external
exportPdf: function(noteId, callback) {
		var me = this;
		// console.log(me.getUrl('note/exportPdf', {noteId: noteId}));
		needle.get(me.getUrl('note/exportPdf', {noteId: noteId}), function(err, resp) {
			me.checkError(err, resp);
			if(err) {
				return callback && callback(false);
			}
			// log(resp.body);
			/*
			{ 'accept-ranges': 'bytes',
			  'content-disposition': 'inline; filename="logo.png"',
			  'content-length': '8583',
			  'content-type': 'image/png',
			  date: 'Mon, 19 Jan 2015 15:01:47 GMT',
  			*/
 
  			var body = resp.body;
  			if(typeof body == "object" && body.Msg === false) {
  				return callback(false, "", body.Msg);
github aripalo / node-irc-bot / commands / so.js View on Github external
el = $(el);

      var row = {
        Title: el.find('.result-link a').text(),
        URL: 'http://stackoverflow.com'+el.find('.result-link a').attr('href')
      };

      results.push(row);

    }.bind(this));

    return results;
  }

  needle.get('http://stackoverflow.com/search?q='+querystring.escape(q), defaultHeaders, function(error, response, body) {
    var results = parseString(body);

    var sendTo = from; // send privately
    if (isChannel(to)) {
      sendTo = to; // send publicly
    }

    client.say(sendTo,
      'Here are the top 3 Stackoverflow results for the search "'+q+'": '
      +'\n1: '+results[0].URL
      +'\n2: '+results[1].URL
      +'\n3: '+results[2].URL
      +'\nMore results at: http://stackoverflow.com/search?q='+querystring.escape(q)
      );

  });
github prey / prey-node-client / lib / package.js View on Github external
releases.get_stable_version = function(cb) {
  needle.get(releases_url + latest_text, function(err, resp, body) {
    var ver = body && body.toString().trim();
    // log('Latest upstream version: ' + ver);

    cb(err, ver);
  });
}
github senecajs / seneca-web / test / test-client.js View on Github external
var assert = require('assert')

var needle = require('needle')



var url = 'http://localhost:3001/t0/a0/b0?a1=b1&a2=b2'
console.log('GET '+url)
needle.get(url,function(err,res){
  assert.ok( !err )
  assert.equal( res.headers.h0, 'i0' )
  assert.deepEqual(res.body,{ r0: 'r0b0', r1: 'r1b1', r2: 'r2b2', x0: 'ry0' })
})


url = 'http://localhost:3001/t0/a0/b0?a1=b1',
console.log('POST '+url)
needle.post(
  url,
  {a2:'b2',c:'c'},
  {json:true},
  function(err,res){
    assert.ok( !err )
    assert.deepEqual(res.body,
                     { r0: 'r0pb0', r1: 'pr1b1', r2: 'r2b2', x0: 'ry0', c: 'C' })
github davidmerfield / Blot / app / clients / git / node_modules / nodegit / node_modules / babel-cli / node_modules / chokidar / node_modules / fsevents / node_modules / node-pre-gyp / lib / install.js View on Github external
}

    var proxyUrl = opts.proxy ||
                    process.env.http_proxy ||
                    process.env.HTTP_PROXY ||
                    process.env.npm_config_proxy;
    if (proxyUrl) {
      if (/^https?:\/\//i.test(proxyUrl)) {
        log.verbose('download', 'using proxy url: "%s"', proxyUrl);
        requestOpts.proxy = proxyUrl;
      } else {
        log.warn('download', 'ignoring invalid "proxy" config setting: "%s"', proxyUrl);
      }
    }
    try {
        req = require('needle').get(requestOpts.uri, requestOpts);
    } catch (e) {
        return callback(e);
    }
    if (req) {
      req.on('response', function (res) {
        log.http(res.statusCode, uri);
      });
    }
    return callback(null,req);
}
github IBM / kui / packages / core / src / webapp / util / fetcher.ts View on Github external
new Promise((resolve, reject) => {
    const tmp = path.join(stagingArea, file)
    const out = fs.createWriteStream(tmp)

    debug('fetchElectron', tmp, url)

    needle
      .get(url)
      .pipe(out)
      .on('error', (err: Error) => {
        console.error(err)
        reject(err)
      })
      .on('finish', () => resolve(tmp))
  })
github weixin / Miaow / node_modules / fsevents / node_modules / node-pre-gyp / lib / install.js View on Github external
}

    var proxyUrl = opts.proxy ||
                    process.env.http_proxy ||
                    process.env.HTTP_PROXY ||
                    process.env.npm_config_proxy;
    if (proxyUrl) {
      if (/^https?:\/\//i.test(proxyUrl)) {
        log.verbose('download', 'using proxy url: "%s"', proxyUrl);
        requestOpts.proxy = proxyUrl;
      } else {
        log.warn('download', 'ignoring invalid "proxy" config setting: "%s"', proxyUrl);
      }
    }
    try {
        req = require('needle').get(requestOpts.uri, requestOpts);
    } catch (e) {
        return callback(e);
    }
    if (req) {
      req.on('response', function (res) {
        log.http(res.statusCode, uri);
      });
    }
    return callback(null,req);
}
github ryangreenhall / insight / lib / resource.js View on Github external
that.get = function(success, failure) {        
      var parsedUrl = Url.parse(url, false);
      needle.get(requestUrl(parsedUrl), basicAuthFrom(parsedUrl), function(error, response, body) {
        if (!error && response.statusCode == 200) {
          success(body);
        } else {
          failure();
        }
      });
    };
    return that;
github mediathekview / mediathekviewweb / server / src / http / client.ts View on Github external
return new Promise>((resolve, reject) => {
      Needle.get(url, { follow: 3 }, (error, response) => {
        if (error != undefined) {
          reject(error);
          return;
        }

        const result: HttpResponse = {
          statusCode: response.statusCode as number,
          statusMessage: response.statusMessage as string,
          body: response.raw
        };

        resolve(result);
      });
    });
  }
github microsoft / BotBuilder-Samples / Node / intelligence-SpeechToText / app.js View on Github external
connector.getAccessToken(function (error, token) {
            var tok = token;
            headers['Authorization'] = 'Bearer ' + token;
            headers['Content-Type'] = 'application/octet-stream';

            return needle.get(attachment.contentUrl, { headers: headers });
        });
    }

needle

The leanest and most handsome HTTP client in the Nodelands.

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis