How to use the request.defaults function in request

To help you get started, we’ve selected a few request 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 cubehouse / PSNjs / psn.js View on Github external
var
	// Vars
	options = { // Default configuration
		debug: 		false
		// @TODO: Using user's account to login and use (it can be used in the browser meaning less server requests)
		,email: 	''
		,password: 	''
		,psnId: ''
		,region: 	'us'
		,npLanguage : 'en'
		,accountId : ''
		,mAccountId: ''
	}
	,regions		= ["us","ca","mx","cl","pe","ar","co","br","gb","ie","be","lu","nl","fr","de","at","ch","it","pt","dk","fi","no","se","au","nz","es","ru","ae","za","pl","gr","sa","cz","bg","hr","ro","si","hu","sk","tr","bh","kw","lb","om","qa","il","mt","is","cy","in","ua","hk","tw","sg","my","id","th","jp","kr"] // Know SONY's servers
	,languages		= ["ja","en","en-GB","fr","es","es-MX","de","it","nl","pt","pt-BR","ru","pl","fi","da","no","sv","tr","ko","zh-CN","zh-TW"] // All languages SONY accepts as parameter
	,request 		= require('request').defaults({jar: true}) // We set jar to true to enable cookie saving (Only used for the login process)
	,debug 			= function (message) {
		if (options.debug) console.log('gPSN | ' + message);
	}
	// Vars required to perform REQUESTS to Sony' servers
	,psnVars = {
		SENBaseURL: 	'https://auth.api.sonyentertainmentnetwork.com'
		,redirectURL_oauth: 'com.scee.psxandroid.scecompcall://redirect'	// Android Callback URL
		,client_id: 	'b0d0d7ad-bb99-4ab1-b25e-afa0c76577b0' 				// Client ID
		,scope: 		'sceapp' 				// SEN Scope
		,scope_psn: 	'psn:sceapp' 			// PSN Scope
		,csrfToken: 	''						// csrf Token
		,authCode : 	''						// authCode needed to ask for an access token
		,client_secret: 'Zo4y8eGIa3oazIEp' 		// Secret string, this is most likely to change overtime. If it changes, please contribute to this project.
		,duid: 			'00000005006401283335353338373035333434333134313a433635303220202020202020202020202020202020' 	// I still don't know what "duid" stands for... if you do, create an issue about it please!
		,cltm: 			'1399637146935'
		,service_entity: 'urn:service-entity:psn'
github shunjikonishi / api-first-spec / lib / httpClient.js View on Github external
function assign(cookieJar, api_, params_, headers_) {
    cookieJar = cookieJar;
    api = api_;
    params = params_;
    headers = headers_;
    request = request.defaults({ jar: cookieJar});
  }
  var 
    self = this,
    request = require("request"),
    cookieJar = request.jar(),
    api = null,
    params = null,
    headers = null;

  request = request.defaults({ jar: cookieJar});

  // Initialize default parameter object
  defaults = defaults || {};
  defaults.params = defaults.params || {};
  defaults.headers = defaults.headers || {};

  function badRequestAll(runDefaults, optionParams) {
    function doIt(desc, data) {
      it(desc, function(done) {
        copy().params(data).badRequest(done);
      });
    }
    function processValue(desc, key, value) {
      var 
        data = extend({}, params),
        orgValue = objectPath.get(data, key);
github TheEssem / esmBot-legacy / commands / screenshot.js View on Github external
const request = require("request").defaults({ encoding: null });
const isURL = require("is-url");
const { MessageEmbed } = require("discord.js");

exports.run = async (client, message, args) => { // eslint-disable-line no-unused-vars
  if (args.length !== 0) {
    message.channel.startTyping();
    const url = isURL(args[0]) ? args[0] : `http://${args[0]}`;
    const screenshot = request(`https://image.thum.io/get/width/1920/crop/675/maxAge/1/noanimate/${url}`);
    const screenshotEmbed = new MessageEmbed()
      .setColor(0xFF0000)
      .setTitle(url)
      .setURL(url)
      .attachFiles([{
        attachment: screenshot,
        name: "screenshot.png"
      }])
github TweetAJoke / TweetAJokeBot / bot.js View on Github external
require('newrelic');
var express     = require('express');
var app         = express();
var http        = require('http').Server(app);
var io          = require('socket.io')(http);
var request     = require('request').defaults({ encoding: null });
var bodyParser  = require('body-parser');
var path        = require('path');

var dotenv      = require('dotenv');
dotenv.load();

// Application configuration
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: true
}));

app.use(express.static(path.join(__dirname, 'public')));

app.set('view engine', 'jade');
app.set('views', path.join(__dirname, 'views'));
github eapowertools / GovernedMetricsService / backup / app.js View on Github external
var qsocks = require('qsocks');
var fs = require('fs');
var request = require('request');

var config = {
	host: 'sense22.112adams.local'
};

//  Set our request defaults, ignore unauthorized cert warnings as default QS certs are self-signed.
//  Export the certificates from your Qlik Sense installation and refer to them
var r = request.defaults({
  rejectUnauthorized: false,
  host: config.host,
  pfx: fs.readFileSync(__dirname + '\\client.pfx'),
  passphrase: 'secret'
});


//  Authenticate whatever user you want
var b = JSON.stringify({
  "UserDirectory": 'sense22',
  "UserId": 'administrator',
  "Attributes": []
});

var meas = {
	qInfo: {
github voxpelli / webpage-webmentions / lib / utils / request.js View on Github external
// @ts-check
/// 
/// 

'use strict';

const options = require('../config');

const request = require('request').defaults({
  jar: false,
  timeout: 5000,
  maxRedirects: 9,
  headers: {
    'User-Agent': options.userAgent
  }
});

module.exports = request;
github Esri / node-geoservices-adaptor / samples / citybikes / resources / bayareabikeshare.js View on Github external
var util = require("util"),
  request = require("request").defaults({json: true});

// BayArea Bike Share data is in JSON and looks like this:
// {
//  "id": 77,
//  "stationName": "Market at Sansome",
//  "availableDocks": 16,
//  "totalDocks": 23,
//  "latitude": 37.789625,
//  "longitude": -122.400811,
//  "statusValue": "In Service",
//  "statusKey": 1,
//  "availableBikes": 7,
//  "stAddress1": "Market at Sansome",
//  "stAddress2": "Market Street",
//  "city": "San Francisco",
//  "postalCode": "",
github imagemin / optipng-bin / build.js View on Github external
if (!(process.platform === 'darwin' || process.platform === 'linux')) {
		return;
	}

	var opts = {
		type: 'Directory',
		path: tmpPath,
		strip: 1
	};

	var proxy = process.env.http_proxy || process.env.HTTP_PROXY ||
		process.env.https_proxy || process.env.HTTPS_PROXY || '';

	console.log(chalk.yellow('Fetching %s...'), urlPath);

	var req = request.defaults({ proxy: proxy }).get(urlPath, function (err, resp) {
		if (resp.statusCode !== 200) {
			throw err;
		}
	});

	req
		.pipe(zlib.Gunzip())
		.pipe(tar.Extract(opts))
		.on('close', function () {
			console.log(chalk.green('Done in %s'), tmpPath);

			which('make', function (err) {
				if (err) {
					throw err;
				}
github chenxianming / quickcms / utils / request.js View on Github external
var request = require('request');
var querystring = require('querystring');
var fs = require('fs');

var FileCookieStore = require('tough-cookie-filestore');
var j = request.jar(new FileCookieStore(__dirname+'/cookies.json'));
request = request.defaults({ jar : j });

module.exports = {
    get:function(url,obj,cb){
        var url = url + '?' + querystring.stringify(obj);
        var args = arguments;
        request({
            url:url,
            method:'get',
            jar:j,
            timeout:3000
        },function(err,data){
            if(err){
                return (typeof args[args.length-1] == 'function') && args[args.length-1](err);
            }
            (typeof args[args.length-1] == 'function') && args[args.length-1](data.body);
        });
github ShyykoSerhiy / skyweb / src / status_service.ts View on Github external
constructor(cookieJar:CookieJar, eventEmitter: EventEmitter) {
        this.requestWithJar = request.defaults({jar: cookieJar});
        this.eventEmitter = eventEmitter;
    }