Interface CompletedBody

interface CompletedBody {
    buffer: Buffer;
    getDecodedBuffer(): Promise<undefined | Buffer>;
    getFormData(): Promise<undefined | {
        [key: string]: string | string[] | undefined;
    }>;
    getJson(): Promise<undefined | object>;
    getMultipartFormData(): Promise<undefined | {
        data: Buffer;
        filename?: string;
        name?: string;
        type?: string;
    }[]>;
    getText(): Promise<undefined | string>;
    getUrlEncodedFormData(): Promise<undefined | {
        [key: string]: string | string[] | undefined;
    }>;
}

Properties

buffer: Buffer

The raw bytes of the response. If a content encoding was used, this is the raw encoded data.

Methods

  • The decoded bytes of the response. If no encoding was used, this is the same as .buffer. The response is decoded and returned asynchronously as a Promise.

    Returns Promise<undefined | Buffer>

  • The contents of the response, decoded, and then parsed automatically as either one of the form encoding types (either URL-encoded or multipart), determined automatically from the message content-type header.

    This method is convenient and offers a single mechanism to parse both formats, but you may want to consider parsing on format explicitly with the getUrlEncodedFormData() or getMultipartFormData() methods instead.

    After parsing & decoding, the result is returned asynchronously as a Promise for a key-value(s) object.

    Returns Promise<undefined | {
        [key: string]: string | string[] | undefined;
    }>

  • The contents of the response, decoded, parsed as UTF-8 string, and then parsed a JSON. The response is decoded and returned asynchronously as a Promise.

    Returns Promise<undefined | object>

  • The contents of the response, decoded, and then parsed as multi-part form data. The response is result is returned asynchronously as a Promise for an array of parts with their names, data and metadata.

    Returns Promise<undefined | {
        data: Buffer;
        filename?: string;
        name?: string;
        type?: string;
    }[]>

  • The contents of the response, decoded and parsed as a UTF-8 string. The response is decoded and returned asynchronously as a Promise.

    Returns Promise<undefined | string>

  • The contents of the response, decoded, parsed as UTF-8 string, and then parsed as URL-encoded form data. After parsing & decoding, the result is returned asynchronously as a Promise for a key-value(s) object.

    Returns Promise<undefined | {
        [key: string]: string | string[] | undefined;
    }>