How to use the needle.post 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
uploadImage: function() {
		var data = {
			foo: 'bar',
			cc: [1,2,3,3],
			dd: {name: 'life', age: 18},
			image: { file: '/Users/life/Desktop/imageplus.png', content_type: 'image/png' }
		}
		needle.post('http://localhost/phpinfo.php', data, { multipart: true }, function(err, resp, body) {
			// needle will read the file and include it in the form-data as binary
			console.log(resp.body);
		});
	}
github clusterio / factorioClusterio / sharedPlugins / inventoryImports / interfacingFunctions.js View on Github external
Object.keys(json.exports).forEach(function(playerName){
				// loop over simpleItemStacks to export
				let stackArray = json.exports[playerName];
				for(let i = 0; i < stackArray.length; i++){
					if(stackArray[i].count > 0){
						// console.log("Returning overflow: " + JSON.stringify(stackArray[i]));
						needle.post(
							config.masterURL + '/api/place',
							stackArray[i],
							{headers: {'x-access-token': config.masterAuthToken}},
							function (err, resp, body) {
								// console.log(body);
							}
						);
					}
				}
			});
		}
github senecajs / seneca-web / test / test-client.js View on Github external
'"o0":"p0","q0":"u0"}' )

  })


var url = 'http://localhost:3001/t0/c1?d0=e0'
console.log('GET '+url)
needle.get(url,function(err,res){
  assert.ok( !err )
  assert.deepEqual( res.body, { d0: 'e0f0' } )
})


url = 'http://localhost:3001/t0/c2',
console.log('POST '+url)
needle.post(
  url,
  {d1:'e1',d2:'e2'},
  {json:true},
  function(err,res){
    assert.ok( !err )
    assert.deepEqual( res.body, { d1: 'e1f1', d2: 'e2' } )
  })

url = 'http://localhost:3001/t0/c2',
console.log('PUT '+url)
needle.put(
  url,
  {d1:'e1',d2:'e2'},
  {json:true},
  function(err,res){
    assert.ok( !err )
github vmazur / smarttvjs / bin / tasks / run.js View on Github external
return;
    }
    var data = {
      mysubmit: "Install",
      archive: {file: 'build/roku.zip'},
    };
    var options = {
      multipart: true,
      auth: 'digest',
      username: 'rokudev',
      password: roku['password'],
    };

    console.log('http://' + roku['ip'] + '/plugin_install');
    console.log(options);
    needle.post('http://' + roku['ip'] + '/plugin_install', data, options, function(err, resp, body) {
      console.log(err);
      console.log(body);
    });
  } else {
    console.log("UNKNOWN: " + name);
  }
};
github Viber / viber-bot-node / lib / viber-client.js View on Github external
return new Promise((resolve, reject) => {
		try {
			needle.post(url, dataWithAuthToken, options)
				.on("data", data => self._readData(data, resolve, reject))
				.on("end", err => self._requestEnded(err, reject))
				.on("err", err => reject(err));
		}
		catch (err) {
			reject(err);
		}
	});
};
github prey / prey-node-client / lib / agent / drivers / control-panel2 / remote.js View on Github external
get_device_data(function(err, data){
    if (err) return callback(err);

    data.name = os.hostname();
    data.type = data.firmware_info && data.firmware_info.device_type || 'Laptop';

    needle.post(attach_url, {device: data}, request_opts, function(err, resp, body){
      if (err) return callback(err);

      if (body.device && body.device.key){
        retrieve_settings(request_opts, body.device.key, callback);
      } else if (resp.statusCode === 302 || resp.headers.location){
        callback(new Error("No available slots on account. Support Prey by upgrading to Pro!"));
      } else if (body.errors && body.errors.error) {
        callback(new Error('Validation error: ' + body.errors.error));
      } else {
        callback(new Error("Unknown response. Could not get device key."));
      }
    });
  });
github prey / prey-node-client / lib / prey / register.js View on Github external
user: function(data, callback){

		var url = common.constants.signup_url;
		var headers = {'User-Agent': common.user_agent};

		http_client.post(url, data, {headers: headers}, function(err, response, body){

			if(err) return callback(false);

			if(response.statusCode == 201 && body.key)
				common.helpers.store_config_value('api_key', body.key, function(err){
					callback(!err);
				});
			else
				callback(false);

		});

	},
github palmerabollo / bingspeech-api-client / src / client.ts View on Github external
return new Promise((resolve, reject) => {
                    let endpoint = this.BING_SPEECH_ENDPOINT_STT + '?' + querystring.stringify(params);
                    needle.post(endpoint, input, options, (err, res, body) => {
                        if (err) {
                            return reject(err);
                        }
                        if (res.statusCode !== 200) {
                            return reject(new Error(`Wrong status code ${res.statusCode} in Bing Speech API / synthesize`));
                        }

                        resolve(body);
                    });
                });
            })
github prey / prey-node-client / lib / one-file / exceptions.js View on Github external
'cwd'       : process.cwd(),
    'language'  : 'node',
    'version'   : process.version,
    'framework' : 'Prey/' + version,
    'platform'  : process.platform,
    'release'   : release(),
    'user'      : process.env.USER || process.env.LOGNAME,
    'args'      : process.argv,
    'env'       : process.env,
    'gid'       : process.getgid && process.getgid(),
    'uid'       : process.getuid && process.getuid(),
    'pid'       : process.pid,
    'memory'    : process.memoryUsage()
  };

  client.post(host, data, opts, function(err, response) {
    cb && cb(err);
  });
};

needle

The leanest and most handsome HTTP client in the Nodelands.

MIT
Latest version published 5 months ago

Package Health Score

77 / 100
Full package analysis