Hierarchy

  • HttpPowers

Index

Methods

Static del

  • Performs an HTTP DELETE request for the URL and options (optional).

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const apiResponse: SkillHttpResponse<unknown> = await HttpPowers.del("https://example.com/somedata");
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static get

  • Performs an HTTP GET request for the URL and options (optional).

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    // Ensure you import the HttpPowers
    // import { HttpPowers, SkillHttpResponse } from "@andi/powers";
    
    const apiResponse: SkillHttpResponse<string> = await HttpPowers.get<string>("https://example.com/somedata");
    const fieldTypeText = apiResponse.data;

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static head

  • Performs an HTTP HEAD request for the URL and options (optional).

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const apiResponse: SkillHttpResponse<string> = await HttpPowers.head("https://example.com/somedata");
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static options

  • Performs an HTTP OPTIONS request for the URL and options (optional).

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const apiResponse: SkillHttpResponse<string> = await HttpPowers.options("https://example.com/somedata");
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static patch

  • Performs an HTTP PATCH request for the URL, data, and options (optional). By default, data will be JSON.stringified, unless params or other options are used.

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const data: {id: "id", information: "information"};
    const apiResponse: SkillHttpResponse<unknown> = await HttpPowers.patch("https://example.com/some/route", data);
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • data: any

      Data to be sent with your request.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static post

  • Performs an HTTP POST request for the URL, data, and options (optional). By default, data will be JSON.stringified, unless params or other options are used.

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const data: {id: "id", information: "information"};
    const apiResponse: SkillHttpResponse<string> = await HttpPowers.post<string>("https://example.com/some/route", data);
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • data: any

      Data to be sent with your request.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Static put

  • Performs an HTTP PUT request for the URL, data, and options (optional). By default, data will be JSON.stringified, unless params or other options are used.

    throws

    {TypeError} when URL or options are not valid.

    throws

    {SkillHttpError} when status code is NOT 200-299.

    throws

    {SkillHttpError} when network or transient errors.

    throws

    {Error} when host cannot be resolved.

    throws

    {Error} when domain is restricted by organization settings.

    example
    const data: {id: "id", information: "information"};
    const apiResponse: SkillHttpResponse<unknown> = await HttpPowers.put("https://example.com/some/route", data);
    

    Type parameters

    • T = unknown

    Parameters

    • url: string

      Valid URL with HTTP scheme and host.

    • data: any

      Data to be sent with your request.

    • Optional options: SkillHttpRequestOptions

      Options to change how your request works.

    Returns Promise<SkillHttpResponse<T>>

Generated using TypeDoc