Skip to content
← Public packages

@kentcdodds/twitch

Monitor Twitch streams, send chat, and update channel settings.

src/request.ts

24 lines · 801 B · TypeScript
import { request, TwitchRequestError } from './core.ts'
import type { TwitchRequestOptions, TwitchResponse } from './types.ts'

export { TwitchRequestError }

/**
 * Perform an authenticated Twitch Helix API request.
 *
 * Uses the `twitch` OAuth integration for both Authorization and Client-Id,
 * which Helix requires together.
 *
 * @returns Parsed response with status, data, and raw text body.
 * @example
 * import request from 'kody:@kentcdodds/twitch/request'
 * const response = await request({ path: '/users', throwOnError: true })
 * // => { ok: true, status: 200, data: { data: [{ login: 'kentcdodds' }] } }
 */
export default async function twitchRequest<T = unknown>(
	params: TwitchRequestOptions,
): Promise<TwitchResponse<T>> {
	return await request<T>(params)
}

export { request }