How to use the http-call.get 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 / commands / pipelines / diff.ts View on Github external
}

  if (downstreamApp.hash === targetApp.hash) {
    return cli.log(`\n${color.app(targetApp.name)} is up to date with ${color.app(downstreamApp.name)}`)
  }

  // Do the actual Github diff
  try {
    const path = `${targetApp.repo}/compare/${downstreamApp.hash}...${targetApp.hash}`
    const headers: { authorization: string; 'user-agent'?: string} = {authorization: 'token ' + githubToken}

    if (herokuUserAgent) {
      headers['user-agent'] = herokuUserAgent
    }

    const githubDiff: any = await HTTP.get(`https://api.github.com/repos/${path}`, {
      headers,
    }).then(res => res.body)

    cli.log('')
    cli.styledHeader(`${color.app(targetApp.name)} is ahead of ${color.app(downstreamApp.name)} by ${githubDiff.ahead_by} commit${githubDiff.ahead_by === 1 ? '' : 's'}`)
    const mapped = githubDiff.commits.map((commit: any) => {
      return {
        sha: commit.sha.substring(0, 7),
        date: commit.commit.author.date,
        author: commit.commit.author.name,
        message: commit.commit.message.split('\n')[0],
      }
    }).reverse()
    cli.table(mapped, {
      sha: {
        header: 'SHA',
github heroku / cli / packages / pipelines / src / github-api.ts View on Github external
request(url: any, options: any = {}) {
    options.headers = {
      Authorization: `Token ${this.token}`,
      'User-Agent': this.version,
      ...options.headers,
    }

    return HTTP.get(`${GITHUB_API}${url}`, options)
  }
github heroku / cli / packages / status / src / commands / status.ts View on Github external
const {flags} = this.parse(Status)
    const apiPath = '/api/v4/current-status'

    const capitalize = (str: string) => str.substr(0, 1).toUpperCase() + str.substr(1)
    const printStatus = (status: string) => {
      const colorize = (color as any)[status]
      let message = capitalize(status)

      if (status === 'green') {
        message = 'No known issues at this time.'
      }
      return colorize(message)
    }

    let host = process.env.HEROKU_STATUS_HOST || 'https://status.heroku.com'
    let {body} = await HTTP.get(host + apiPath)

    if (flags.json) {
      cli.styledJSON(body)
      return
    }

    for (let item of body.status) {
      let message = printStatus(item.status)

      this.log(`${(item.system + ':').padEnd(11)}${message}`)
    }

    for (let incident of body.incidents) {
      cli.log()
      cli.styledHeader(`${incident.title} ${color.yellow(incident.created_at)} ${color.cyan(incident.full_url)}`)

http-call

make http requests

ISC
Latest version published 4 years ago

Package Health Score

66 / 100
Full package analysis