@types/superagent

  • Version 4.1.24
  • Published
  • 11.6 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/superagent
yarn add @types/superagent
pnpm add @types/superagent

Overview

TypeScript definitions for superagent

Index

Variables

variable request

const request: request.SuperAgentStatic;

    Interfaces

    interface HTTPError

    interface HTTPError extends Error {}

      property method

      method: string;

        property path

        path: string;

          property status

          status: number;

            property text

            text: string;

              interface ProgressEvent

              interface ProgressEvent {}

                property direction

                direction: 'download' | 'upload';

                  property loaded

                  loaded: number;

                    property percent

                    percent?: number | undefined;

                      property total

                      total?: number | undefined;

                        interface Request

                        interface Request extends Promise<Response> {}

                          method abort

                          abort: () => void;

                            method accept

                            accept: (type: string) => this;

                              method attach

                              attach: (
                              field: string,
                              file: MultipartValueSingle,
                              options?:
                              | string
                              | { filename?: string | undefined; contentType?: string | undefined }
                              ) => this;

                                method auth

                                auth: {
                                (user: string, pass: string, options?: { type: 'basic' | 'auto' }): this;
                                (token: string, options: { type: 'bearer' }): this;
                                };

                                  method buffer

                                  buffer: (val?: boolean) => this;

                                    method ca

                                    ca: (cert: string | string[] | Buffer | Buffer[]) => this;

                                      method cert

                                      cert: (cert: string | string[] | Buffer | Buffer[]) => this;

                                        method clearTimeout

                                        clearTimeout: () => this;

                                          method connect

                                          connect: (
                                          override:
                                          | string
                                          | { [hostname: string]: string | false | { host: string; port: number } }
                                          ) => this;

                                            method disableTLSCerts

                                            disableTLSCerts: () => this;

                                              method end

                                              end: (callback?: CallbackHandler) => void;

                                                method field

                                                field: {
                                                (name: string, val: MultipartValue): this;
                                                (fields: { [fieldName: string]: any }): this;
                                                };

                                                  method get

                                                  get: (field: string) => string;

                                                    method http2

                                                    http2: (enable?: boolean) => this;

                                                      method key

                                                      key: (cert: string | string[] | Buffer | Buffer[]) => this;

                                                        method maxResponseSize

                                                        maxResponseSize: (size: number) => this;

                                                          method ok

                                                          ok: (callback: (res: Response) => boolean) => this;

                                                            method on

                                                            on: {
                                                            (name: 'error', handler: (err: any) => void): this;
                                                            (name: 'progress', handler: (event: ProgressEvent) => void): this;
                                                            (name: 'response', handler: (response: Response) => void): this;
                                                            (name: string, handler: (event: any) => void): this;
                                                            };

                                                              method parse

                                                              parse: (parser: Parser) => this;

                                                                method part

                                                                part: () => this;

                                                                  method pfx

                                                                  pfx: (
                                                                  cert:
                                                                  | string
                                                                  | string[]
                                                                  | Buffer
                                                                  | Buffer[]
                                                                  | { pfx: string | Buffer; passphrase: string }
                                                                  ) => this;

                                                                    method pipe

                                                                    pipe: (stream: NodeJS.WritableStream, options?: object) => stream.Writable;

                                                                      method query

                                                                      query: (val: object | string) => this;

                                                                        method redirects

                                                                        redirects: (n: number) => this;

                                                                          method responseType

                                                                          responseType: (type: string) => this;

                                                                            method retry

                                                                            retry: (count?: number, callback?: CallbackHandler) => this;

                                                                              method send

                                                                              send: (data?: string | object) => this;

                                                                                method serialize

                                                                                serialize: (serializer: Serializer) => this;

                                                                                  method set

                                                                                  set: {
                                                                                  (field: object): this;
                                                                                  (field: string, val: string): this;
                                                                                  (field: 'Cookie', val: string[]): this;
                                                                                  };

                                                                                    method timeout

                                                                                    timeout: (
                                                                                    ms: number | { deadline?: number | undefined; response?: number | undefined }
                                                                                    ) => this;

                                                                                      method trustLocalhost

                                                                                      trustLocalhost: (enabled?: boolean) => this;

                                                                                        method type

                                                                                        type: (val: string) => this;

                                                                                          method unset

                                                                                          unset: (field: string) => this;

                                                                                            method use

                                                                                            use: (fn: Plugin) => this;

                                                                                              method withCredentials

                                                                                              withCredentials: (on?: boolean) => this;

                                                                                                method write

                                                                                                write: (data: string | Buffer, encoding?: string) => boolean;

                                                                                                  interface Response

                                                                                                  interface Response extends NodeJS.ReadableStream {}

                                                                                                    property accepted

                                                                                                    accepted: boolean;

                                                                                                      property badRequest

                                                                                                      badRequest: boolean;

                                                                                                        property body

                                                                                                        body: any;

                                                                                                          property charset

                                                                                                          charset: string;

                                                                                                            property clientError

                                                                                                            clientError: boolean;

                                                                                                              property error

                                                                                                              error: false | HTTPError;

                                                                                                                property files

                                                                                                                files: any;

                                                                                                                  property forbidden

                                                                                                                  forbidden: boolean;

                                                                                                                    property header

                                                                                                                    header: { [index: string]: string };

                                                                                                                      property headers

                                                                                                                      headers: { [index: string]: string };

                                                                                                                        property info

                                                                                                                        info: boolean;
                                                                                                                          links: Record<string, string>;

                                                                                                                            property noContent

                                                                                                                            noContent: boolean;

                                                                                                                              property notAcceptable

                                                                                                                              notAcceptable: boolean;

                                                                                                                                property notFound

                                                                                                                                notFound: boolean;

                                                                                                                                  property ok

                                                                                                                                  ok: boolean;

                                                                                                                                    property redirect

                                                                                                                                    redirect: boolean;

                                                                                                                                      property redirects

                                                                                                                                      redirects: string[];

                                                                                                                                        property serverError

                                                                                                                                        serverError: boolean;

                                                                                                                                          property status

                                                                                                                                          status: number;

                                                                                                                                            property statusCode

                                                                                                                                            statusCode: number;

                                                                                                                                              property statusType

                                                                                                                                              statusType: number;

                                                                                                                                                property text

                                                                                                                                                text: string;

                                                                                                                                                  property type

                                                                                                                                                  type: string;

                                                                                                                                                    property unauthorized

                                                                                                                                                    unauthorized: boolean;

                                                                                                                                                      property xhr

                                                                                                                                                      xhr: any;

                                                                                                                                                        method get

                                                                                                                                                        get: { (header: string): string; (header: 'Set-Cookie'): string[] };

                                                                                                                                                          interface ResponseError

                                                                                                                                                          interface ResponseError extends Error {}

                                                                                                                                                            property response

                                                                                                                                                            response?: Response | undefined;

                                                                                                                                                              property status

                                                                                                                                                              status?: number | undefined;

                                                                                                                                                                property timeout

                                                                                                                                                                timeout?: boolean | undefined;

                                                                                                                                                                  interface SuperAgent

                                                                                                                                                                  interface SuperAgent<Req extends SuperAgentRequest> extends stream.Stream {}

                                                                                                                                                                    property jar

                                                                                                                                                                    jar: cookiejar.CookieJar;

                                                                                                                                                                      method attachCookies

                                                                                                                                                                      attachCookies: (req: Req) => void;

                                                                                                                                                                        method checkout

                                                                                                                                                                        checkout: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                          method connect

                                                                                                                                                                          connect: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                            method copy

                                                                                                                                                                            copy: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                              method del

                                                                                                                                                                              del: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                method delete

                                                                                                                                                                                delete: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                  method get

                                                                                                                                                                                  get: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                    method head

                                                                                                                                                                                    head: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                      method lock

                                                                                                                                                                                      lock: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                        method merge

                                                                                                                                                                                        merge: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                          method mkactivity

                                                                                                                                                                                          mkactivity: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                            method mkcol

                                                                                                                                                                                            mkcol: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                              method move

                                                                                                                                                                                              move: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                method notify

                                                                                                                                                                                                notify: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                  method options

                                                                                                                                                                                                  options: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                    method patch

                                                                                                                                                                                                    patch: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                      method post

                                                                                                                                                                                                      post: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                        method propfind

                                                                                                                                                                                                        propfind: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                          method proppatch

                                                                                                                                                                                                          proppatch: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                            method purge

                                                                                                                                                                                                            purge: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                              method put

                                                                                                                                                                                                              put: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                method report

                                                                                                                                                                                                                report: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                  method saveCookies

                                                                                                                                                                                                                  saveCookies: (res: Response) => void;

                                                                                                                                                                                                                    method search

                                                                                                                                                                                                                    search: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                      method subscribe

                                                                                                                                                                                                                      subscribe: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                        method trace

                                                                                                                                                                                                                        trace: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                          method unlock

                                                                                                                                                                                                                          unlock: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                            method unsubscribe

                                                                                                                                                                                                                            unsubscribe: (url: string, callback?: CallbackHandler) => Req;

                                                                                                                                                                                                                              interface SuperAgentRequest

                                                                                                                                                                                                                              interface SuperAgentRequest extends Request {}

                                                                                                                                                                                                                                property cookies

                                                                                                                                                                                                                                cookies: string;

                                                                                                                                                                                                                                  property method

                                                                                                                                                                                                                                  method: string;

                                                                                                                                                                                                                                    property url

                                                                                                                                                                                                                                    url: string;

                                                                                                                                                                                                                                      method agent

                                                                                                                                                                                                                                      agent: (agent?: http.Agent) => this;

                                                                                                                                                                                                                                        interface SuperAgentStatic

                                                                                                                                                                                                                                        interface SuperAgentStatic extends SuperAgent<SuperAgentRequest> {}

                                                                                                                                                                                                                                          property parse

                                                                                                                                                                                                                                          parse: { [type: string]: Parser };

                                                                                                                                                                                                                                            property serialize

                                                                                                                                                                                                                                            serialize: { [type: string]: Serializer };

                                                                                                                                                                                                                                              method agent

                                                                                                                                                                                                                                              agent: () => this & Request;

                                                                                                                                                                                                                                                call signature

                                                                                                                                                                                                                                                (url: string): SuperAgentRequest;

                                                                                                                                                                                                                                                  call signature

                                                                                                                                                                                                                                                  (method: string, url: string): SuperAgentRequest;

                                                                                                                                                                                                                                                    Type Aliases

                                                                                                                                                                                                                                                    type BrowserParser

                                                                                                                                                                                                                                                    type BrowserParser = (str: string) => any;

                                                                                                                                                                                                                                                      type CallbackHandler

                                                                                                                                                                                                                                                      type CallbackHandler = (err: any, res: request.Response) => void;

                                                                                                                                                                                                                                                        type MultipartValue

                                                                                                                                                                                                                                                        type MultipartValue = MultipartValueSingle | MultipartValueSingle[];

                                                                                                                                                                                                                                                          type MultipartValueSingle

                                                                                                                                                                                                                                                          type MultipartValueSingle =
                                                                                                                                                                                                                                                          | Blob
                                                                                                                                                                                                                                                          | Buffer
                                                                                                                                                                                                                                                          | fs.ReadStream
                                                                                                                                                                                                                                                          | string
                                                                                                                                                                                                                                                          | boolean
                                                                                                                                                                                                                                                          | number;

                                                                                                                                                                                                                                                            type NodeParser

                                                                                                                                                                                                                                                            type NodeParser = (
                                                                                                                                                                                                                                                            res: request.Response,
                                                                                                                                                                                                                                                            callback: (err: Error | null, body: any) => void
                                                                                                                                                                                                                                                            ) => void;

                                                                                                                                                                                                                                                              type Parser

                                                                                                                                                                                                                                                              type Parser = BrowserParser | NodeParser;

                                                                                                                                                                                                                                                                type Plugin

                                                                                                                                                                                                                                                                type Plugin = (req: SuperAgentRequest) => void;

                                                                                                                                                                                                                                                                  type Serializer

                                                                                                                                                                                                                                                                  type Serializer = (obj: any) => string;

                                                                                                                                                                                                                                                                    Package Files (1)

                                                                                                                                                                                                                                                                    Dependencies (2)

                                                                                                                                                                                                                                                                    Dev Dependencies (0)

                                                                                                                                                                                                                                                                    No dev dependencies.

                                                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/superagent.

                                                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/superagent)
                                                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/@types/superagent"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>