centurion-ui
    Preparing search index...

    Function jsonHttpRequest

    • This object is intended to serve as the single point for all HTTP requests that are expected to send / receive json data.

      This object is a wrapper for httpRequest that adds the required information to the request as well as performs validation.

      When calling this fetcher, ensure that you have at least provided a url and the body (if method PATCH or POST) to make the request.


      const myRequest = jsonHttpRequest({
      url: "https://my-domain-name.tld/some-path",
      method: "POST",
      body: {
      "a_key": "a value"
      }
      })

      Parameters

      • __namedParameters: HTTPNamedParams

        Named parameters for a HTTP request.

        • Optionalbody?: BodyInit

          Body to use for request.

        • Optionalcredentials?: "omit" | "include" | "same-origin"

          Send Credentials with request.

          When set to true credentials will be set to same-orign

        • Optionalheaders?: HeadersInit

          Headers to add to the request.

        • Optionalmethod?: "GET" | "OPTIONS" | "POST" | "PATCH"

          HTTP method to use for the request.

        • Optionalmode?: "same-origin" | "no-cors" | "cors"
        • OptionalreferrerPolicy?: ReferrerPolicy
        • Optionalsignal?: AbortSignal

          Request signal.

        • url: string

          URL for the request to be made against.

      Returns Promise<Response>

      Error if the method is "PATCH" or "POST" and the body is empty.

      0.13.0