Skip to content
← Public packages

@kody/github

Call GitHub REST, GraphQL, and pull requests with a GitHub OAuth App or a personal access token.

src/request.ts

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

/**
 * Make one authenticated GitHub REST API request.
 *
 * Mutating methods (`POST`, `PUT`, `PATCH`, `DELETE`) require `dryRun: true`
 * or `confirm: true`.
 *
 * @returns Normalized response with `ok`, `status`, `data`, and `text`.
 * @example
 * import githubRequest from 'kody:@kody/github/request'
 * const response = await githubRequest({ path: '/user' })
 * // => { ok: true, status: 200, data: { login: '...' } }
 */
export default async function githubRequest(params: GitHubRequestOptions) {
  return await request(params)
}