UNPKG

1.35 kBTypeScriptView Raw
1import { GaxiosError, GaxiosOptions, GaxiosPromise, GaxiosResponse } from 'gaxios';
2export interface Transporter {
3 request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
4 request<T>(opts: GaxiosOptions, callback?: BodyResponseCallback<T>): void;
5 request<T>(opts: GaxiosOptions, callback?: BodyResponseCallback<T>): GaxiosPromise | void;
6}
7export interface BodyResponseCallback<T> {
8 (err: Error | null, res?: GaxiosResponse<T> | null): void;
9}
10export interface RequestError extends GaxiosError {
11 errors: Error[];
12}
13export declare class DefaultTransporter {
14 /**
15 * Default user agent.
16 */
17 static readonly USER_AGENT: string;
18 /**
19 * Configures request options before making a request.
20 * @param opts GaxiosOptions options.
21 * @return Configured options.
22 */
23 configure(opts?: GaxiosOptions): GaxiosOptions;
24 /**
25 * Makes a request using Gaxios with given options.
26 * @param opts GaxiosOptions options.
27 * @param callback optional callback that contains GaxiosResponse object.
28 * @return GaxiosPromise, assuming no callback is passed.
29 */
30 request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
31 request<T>(opts: GaxiosOptions, callback?: BodyResponseCallback<T>): void;
32 /**
33 * Changes the error to include details from the body.
34 */
35 private processError;
36}