How to use unirest - 10 common examples

To help you get started, we’ve selected a few unirest 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 BroNils / LINE-FreshBot / pkg / main.js View on Github external
loginWithVerifier: function(xthrift, xconfig, callback) {
        let reqx = new TTypes.LoginRequest();
        console.info(config.Headers);
        unirest.get('https://' + config.LINE_DOMAIN + config.LINE_CERTIFICATE_URL).headers(config.headers).timeout(120000)
            .end((res) => {
                reqx.type = 1;
                reqx.verifier = res.body.result.verifier;
                xthrift.loginZ(reqx, (err, success) => {
                    callback(success);
                })
            })
    },
github pantsel / konga / api / services / ConsumerService.js View on Github external
var getConsumers = function (prevConsumers,url) {
            unirest.get(url)
                .end(function(response) {
                    if (response.error) return cb(response);
                    var kongConsumers = prevConsumers.concat(response.body.data);
                    if (response.body.next) {
                        getConsumers(kongConsumers,response.body.next);
                    }
                    else {
                        handleConsumers(kongConsumers);
                    }

                });
        };
        getConsumers([],sails.config.kong_admin_url + '/consumers');
github pantsel / konga / api / controllers / KongPluginController.js View on Github external
retrieveEnabled : function(req,res) {
        unirest.get(sails.config.kong_admin_url + '/plugins/enabled/')
            .end(function(response){
                if(response.error) return res.kongError(response)
                return res.json(response.body)
            })
    },
github pantsel / konga / api / services / ConsumerCredentialsService.js View on Github external
promises.push(function(cb) {
                unirest.get(sails.config.kong_admin_url + '/consumers/' + consumer_id + "/" + credential)
                    .end(function(response){
                        if(response.error) return  cb({
                            status : response.error.status,
                            message : response.body.message
                        })
                        return cb(null,{
                            name : credential,
                            data : response.body.data,
                            total : response.body.total
                        })
                    })
            })
        })
github pantsel / konga / api / controllers / KongConsumerController.js View on Github external
retrieveCredentials : function(req,res) {
        unirest.get(sails.config.kong_admin_url + '/consumers/' + req.params.id + "/" + req.params.credential)
            .end(function(response){
                if(response.error) return  res.kongError(response)
                return res.json(response.body)
            })
    },
github pantsel / konga / api / controllers / KongInfoController.js View on Github external
status : function(req,res) {
        unirest.get(( req.query.kong_admin_url || sails.config.kong_admin_url ) + "/status")
            .end(function(response){
                if(response.error) return res.negotiate(response.error)
                return res.json(response.body)
            })
    },
github callmekory / nezuko / src / commands / media / Ombi Series.ts View on Github external
const getTVDBID = async (name) => {
      try {
        const response = await get(urljoin(host, '/api/v1/Search/tv/', name)).headers({
          accept: 'application/json',
          ApiKey: apiKey
        })
        return response.body
      } catch (e) {
        const text = 'Failed to connect to Ombi'
        Log.error('Ombi Movies', text, e)
        await errorMessage(msg, text)
      }
    }
github callmekory / nezuko / src / commands / media / Ombi Movies.ts View on Github external
const getTMDbID = async (name) => {
      try {
        const response = await get(urljoin(host, '/api/v1/Search/movie/', name)).headers({
          accept: 'application/json',
          ApiKey: apiKey,
          'User-Agent': `Mellow/${process.env.npm_package_version}`
        })
        return response.body
      } catch (e) {
        const text = 'Failed to connect to Ombi'
        Log.error('Ombi Movies', text, e)
        await errorMessage(msg, text)
      }
    }
github callmekory / nezuko / src / commands / smart home / PioneerAVR.ts View on Github external
const setPower = async (onoff) => {
      const state = onoff === 'on' ? 'PO' : 'PF'
      await get(urljoin(host, `/EventHandler.asp?WebToHostItem=${state}`)).headers({
        accept: 'application/json'
      })
      if (api) return `AVR turned [ ${capitalize(onoff)} ]`
      return standardMessage(msg, `:radio: AVR turned [ ${capitalize(onoff)} ]`)
    }
github pantsel / konga / api / services / KongService.js View on Github external
retrieve: function (req, res) {
    unirest.get(Utils.withoutTrailingSlash(req.connection.kong_admin_url) + req.url.replace('/kong', ''))
      .headers(KongService.headers(req, true))
      .end(function (response) {
        if (response.error) return res.kongError(response);
        return res.json(response.body);
      });
  },

unirest

Simplified, lightweight HTTP client library

MIT
Latest version published 6 years ago

Package Health Score

47 / 100
Full package analysis

Popular unirest functions