Interface MandeInstance

Object returned by mande

interface MandeInstance {
    options: Required<Pick<OptionsRaw<ResponseAsTypes>, "headers">> & Omit<OptionsRaw<ResponseAsTypes>, "headers">;
    delete<T, R>(options?: Options<R>): MandeResponse<T, R>;
    delete<T, R>(url: string | number, options?: Options<R>): MandeResponse<T, R>;
    get<T, R>(options?: Options<R>): MandeResponse<T, R>;
    get<T, R>(url: string | number, options?: Options<R>): MandeResponse<T, R>;
    patch<T, R>(data?: any, options?: Options<R>): MandeResponse<T, R>;
    patch<T, R>(url: string | number, data?: any, options?: Options<R>): MandeResponse<T, R>;
    post<T, R>(data?: any, options?: Options<R>): MandeResponse<T, R>;
    post<T, R>(url: string | number, data?: any, options?: Options<R>): MandeResponse<T, R>;
    put<T, R>(data?: any, options?: Options<R>): MandeResponse<T, R>;
    put<T, R>(url: string | number, data?: any, options?: Options<R>): MandeResponse<T, R>;
}

Properties

Methods

Properties

options: Required<Pick<OptionsRaw<ResponseAsTypes>, "headers">> & Omit<OptionsRaw<ResponseAsTypes>, "headers">

Writable options.

Methods

  • Sends a POST request to the base url. This is equivalent to calling post with an empty string.

    Type Parameters

    Parameters

    • Optionaldata: any

      optional body of the request

    • Optionaloptions: Options<R>

      optional Options

    Returns MandeResponse<T, R>

    const createdUser = await users.post({ name: 'Eduardo' })
    
  • Sends a POST request to the given url.

    Type Parameters

    Parameters

    • url: string | number

      relative url to send the request to

    • Optionaldata: any

      optional body of the request

    • Optionaloptions: Options<R>

      optional Options

    Returns MandeResponse<T, R>

    const createdUser = await users.post('', { name: 'Eduardo' })
    
  • Sends a PUT request to the base url. This is equivalent to calling put with an empty string.

    Type Parameters

    Parameters

    • Optionaldata: any

      optional body of the request

    • Optionaloptions: Options<R>

      optional Options

    Returns MandeResponse<T, R>

    users.put({ name: 'Eduardo' })
    
  • Sends a PUT request to the given url.

    Type Parameters

    Parameters

    • url: string | number

      relative url to send the request to

    • Optionaldata: any

      optional body of the request

    • Optionaloptions: Options<R>

      optional Options

    Returns MandeResponse<T, R>

    users.put('2', { name: 'Eduardo' })