Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kentcdodds/github

src/request.ts

19 lines · 772 B · TypeScript
import type { GitHubRequestOptions } from "./types"
export { GitHubRequestError, GitHubRequestTimeoutError, request } from "./core"
import { request } from "./core"

/**
 * Make one authenticated GitHub REST API request.
 *
 * Optional `timeoutMs` / `signal` bound the underlying fetch. Omit them for
 * ordinary reads; pass a budget for long-lived mutations that can hang.
 *
 * @returns Normalized response with `ok`, `status`, `data`, and `text`.
 * @example
 * import githubRequest from 'kody:@kentcdodds/github/request'
 * const response = await githubRequest({ account: 'bot', path: '/user' })
 * // => { ok: true, status: 200, data: { login: '...' } }
 */
export default async function githubRequest(params: GitHubRequestOptions) {
  return await request(params)
}