Skip to content

@loontail/minecraft-kit v0.8.14 / HttpRequestOptions

Type alias: HttpRequestOptions

ts
type HttpRequestOptions: {
  acceptNonOk: boolean;
  body: HttpRequestBody;
  headers: HttpHeaders;
  method: HttpMethod;
  noCache: boolean;
  signal: AbortSignal;
  timeoutMs: number;
};

Options for an HTTP request.

Example

ts
import type { HttpClient, HttpRequestOptions } from "@loontail/minecraft-kit";

const fetchJson = (http: HttpClient, url: string, signal: AbortSignal) => {
  const options: HttpRequestOptions = { signal, timeoutMs: 30_000 };
  return http.request(url, options).then((r) => r.json());
};

Type declaration

MemberTypeDescription
acceptNonOkbooleanWhen true, the client returns the response even for non-2xx statuses instead of throwing. Useful for callers that must inspect the body of error responses (e.g. OAuth polling endpoints that return 400 with structured JSON like {"error":"authorization_pending"}).
bodyHttpRequestBodyRequest body. Ignored for GET.
headersHttpHeaders-
methodHttpMethodHTTP method. Defaults to GET.
noCachebooleanWhen true, do not consult the in-memory cache.
signalAbortSignal-
timeoutMsnumber-

Source

src/types/http.ts:77

MIT License