How to use the http-call.HTTP.request function in http-call

To help you get started, we’ve selected a few http-call 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 heroku / cli / packages / pipelines / src / kolkrabbi-api.ts View on Github external
request(url: string, options: any = {}) {
    options.headers = {
      Authorization: `Bearer ${this.token}`,
      'User-Agent': this.version
    }

    if (['POST', 'PATCH', 'DELETE'].includes(options.method)) {
      options.headers['Content-type'] = 'application/json'
    }

    return HTTP.request(KOLKRABBI_BASE_URL + url, options).then((res: any) => res.body)
  }
github jdxcode / npm-register / lib / npm.js View on Github external
async function get (name, etag) {
  try {
    if (etag && redis && (await isEtagFresh(name, etag))) return 304
    let pkg = redis ? await fetchFromCache(name) : null
    if (pkg) return pkg
    let req = await HTTP.request(url.resolve(config.uplink.href, '/' + name.replace(/\//, '%2F')), getRequestOpts(etag))
    pkg = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
    if (!pkg.versions) return 404
    pkg.etag = req.response.headers.etag
    updateCache(pkg)
    return pkg
  } catch (err) {
    switch (err.statusCode) {
      case 304:
        if (redis) updateEtag(name, etag)
        return 304
      case 404:
        return 404
      default:
        warn(err, {pkg: name})
        return 404
    }

http-call

make http requests

ISC
Latest version published 4 years ago

Package Health Score

66 / 100
Full package analysis