Tabnine Logo For Javascript
r
Code IndexAdd Tabnine to your IDE (free)

How to use
r
function
in
request

Best JavaScript code snippets using request.r(Showing top 3 results out of 5,391)

origin: lirantal/agilemanager-api

// create the resource request
  r({
    uri: uri,
    method: resourceOptions.method,
    headers: authHeader,
    body: payload,
    json: true
  }, function(error, response, body) {
    if (error) {
      // On error, return the error object
      return cb(new Error(error), response.body);
    } else if (response.body.error && response.body.error === 'unauthorized' && response.statusCode === 401) {
      // On authorization error, try to authenticate
      return self.login(function() {
        self.resource(resourceOptions, cb);
      });
    } else if (response.statusCode === 200 || response.statusCode === 201) {
      return cb(null, response.body);
    } else {
      return cb(new Error(response.body), response.body);
    }
  });
origin: lirantal/agilemanager-api

// make a new request to gain access_token
    r({
      uri: actionUrl.login,
      method: 'POST',
      form: {
        client_id: this.clientId,
        client_secret: this.clientSecret,
        grant_type: 'client_credentials'
      },
      json: true
    }, function(error, response, body) {
      if (error) {
        return cb(new Error(error), null);
      } else if (response.statusCode === 200 && body.access_token) {
        self.token = {
          access_token: body.access_token,
          token_type: body.token_type,
          expires_in: body.expires_in,
          scope: body.scope
        };
        return cb(null, self.token);
      } else {
        return cb(new Error(response.body), null);
      }
    });
origin: lirantal/agilemanager-api

// create the query request
  r({
    uri: uri,
    method: 'GET',
    headers: authHeader,
    qs: {
      query: '"' + queryOptions.query + '"',
      fields: queryOptions.fields,
      orderBy: queryOptions.orderBy,
      limit: queryOptions.limit,
      offset: queryOptions.offset
    },
    json: true
  }, function(error, response, body) {
    if (error) {
      // On error, return the error object
      return cb(new Error(error), response.body);
    } else if (response.body.error && response.body.error === 'unauthorized' && response.statusCode === 401) {
      // On authorization error, try to authenticate
      return self.login(function() {
        self.query(queryOptions, cb);
      });
    } else if (response.statusCode === 200) {
      return cb(null, response.body);
    } else {
      return cb(new Error(response.body), response.body);
    }
  });
request(npm)r

Most used request functions

  • request
  • Response.statusCode
  • RequestAPI.post
  • RequestAPI.get
  • Request.pipe
  • rp,
  • Request.on,
  • Response.headers,
  • RequestAPI.defaults,
  • RequestAPI.put,
  • RequestAPI.jar,
  • Response.statusMessage,
  • RequestAPI.head,
  • Response.on,
  • RequestAPI.cookie,
  • RequestAPI.delete,
  • Response.pipe,
  • RequestAPI.del,
  • requestRetry

Popular in JavaScript

  • aws-sdk
    AWS SDK for JavaScript
  • glob
    a little globber
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • mocha
    simple, flexible, fun test framework
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • node-fetch
    A light-weight module that brings window.fetch to node.js
  • request
    Simplified HTTP request client.
  • fs
  • colors
    get colors in your node.js console
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now