How to use the @octokit/request.request function in @octokit/request

To help you get started, we’ve selected a few @octokit/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 octokit / webhooks / lib / create-pr-on-change.js View on Github external
// push changes back to GitHub
  await execa('git', ['checkout', '-b', branchName])
  await execa('git', ['add', 'cache'])
  await execa('git', ['commit', '-m', 'build: cache'])
  await execa('git', ['add', '.'])
  await execa('git', ['commit', '-m', 'build: webhooks'])
  await execa('git', [
    'push',
    `https://${process.env.GH_TOKEN}@github.com/${owner}/${repo}.git`,
    `HEAD:${branchName}`
  ])
  await execa('git', ['checkout', '-'])

  // start pullrequest
  const { body } = await request('POST /repos/:owner/:repo/pulls', {
    owner,
    repo,
    headers: {
      authorization: `token ${process.env.GH_TOKEN}`
    },
    title: `🤖🚨 ${changesSummary}`,
    head: branchName,
    base: 'master',
    body: `Dearest humans,

My friend Travis asked me to let you know that they found webhook changes in their daily routine check.`
  })

  console.log(`🤖  Pull request created: ${body.html_url}`)
}
github octokit / rest.js / test / util.js View on Github external
function loadFixture(scenario) {
  return request("POST http://localhost:3000/fixtures", {
    data: JSON.stringify({ scenario })
  })
    .then(response => response.data)

    .catch(error => {
      if (error.status === "ECONNREFUSED") {
        throw new Error(
          'Fixtures server could not be reached. Make sure to start it with "npm run start-fixtures-server"'
        );
      }

      throw error;
    });
}
github octokit / webhooks / lib / get-html.js View on Github external
async function getHtml (state) {
  const cacheFilePath = 'event-types-and-payloads.html'

  if (state.cached && await cache.exists(cacheFilePath)) {
    return cache.read(cacheFilePath)
  }

  console.log(`⌛  fetching ${WEBHOOKS_DOCS_URL}`)

  const { data: html } = await request(WEBHOOKS_DOCS_URL)
  await cache.writeHtml(cacheFilePath, html)
  return html
}
github kaisermann / pr-slack-bot / src / api / github.js View on Github external
const cached_signature = get_cached_etag(url, request_signature);
  if (cached_signature != null) {
    request_headers['If-None-Match'] = cached_signature;
  }

  if (installationId == null) {
    installationId = await get_installation_id(full_name);
    db.installations.set_id(full_name, installationId);
  }

  try {
    const installationAccessToken = await github_app.getInstallationAccessToken(
      { installationId },
    );

    const response = await request(url, {
      ...options,
      headers: {
        ...request_headers,
        authorization: `token ${installationAccessToken}`,
      },
    });

    const { etag } = response.headers;
    REQUEST_SIGNATURES[url][request_signature] = etag;

    return response;
  } catch (e) {
    return e;
  }
};
github eduardoboucas / staticman / lib / GitHub.js View on Github external
async _authenticate (username, repository) {
    const app = new App(
      {
        id: config.get('githubAppID'),
        privateKey: config.get('githubPrivateKey'),
        baseUrl: config.get('githubBaseUrl')
      }
    )

    const jwt = app.getSignedJsonWebToken()

    const {data} = await request('GET /repos/:owner/:repo/installation', {
      owner: username,
      repo: repository,
      headers: {
        authorization: `Bearer ${jwt}`,
        accept: 'application/vnd.github.machine-man-preview+json'
      }
    })

    const installationId = data.id

    let token = await app.getInstallationAccessToken({installationId})

    return token
  }

@octokit/request

Send parameterized requests to GitHub's APIs with sensible defaults in browsers and Node

MIT
Latest version published 4 months ago

Package Health Score

90 / 100
Full package analysis