mockttp
    Preparing search index...

    Interface CompletedBody

    interface CompletedBody {
        buffer: Buffer;
        getDecodedBuffer(): Promise<Buffer<ArrayBufferLike> | undefined>;
        getFormData(): Promise<
            { [key: string]: string | string[] | undefined }
            | undefined,
        >;
        getJson<R = string | number | boolean | object | null>(): Promise<
            R
            | undefined,
        >;
        getMultipartFormData(): Promise<
            | { data: Buffer; filename?: string; name?: string; type?: string }[]
            | undefined,
        >;
        getText(): Promise<string | undefined>;
        getUrlEncodedFormData(): Promise<
            { [key: string]: string | string[] | undefined }
            | undefined,
        >;
    }
    Index
    buffer: Buffer

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

    • 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<Buffer<ArrayBufferLike> | undefined>

    • 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<{ [key: string]: string | string[] | undefined } | 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. This returns undefined if the body can't be decoded or isn't valid JSON.

      The result covers any JSON value by default, or you can pass a type argument to set the type you expect.

      Type Parameters

      • R = string | number | boolean | object | null

      Returns Promise<R | undefined>

    • 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<
          | { data: Buffer; filename?: string; name?: string; type?: string }[]
          | undefined,
      >

    • 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<string | undefined>

    • 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<{ [key: string]: string | string[] | undefined } | undefined>