method WebClient.prototype.request
WebClient.prototype.request(
path: string,
method: Method,
options?: RequestOptions,
body?: unknown,
): Task<ResponseResult, HttpError>

Make an HTTP request with the specified method.

Examples

Example 1

// Simple GET
const result = await client.request("/users", "GET").run();

// POST with body and options
const result = await client.request(
  "/users",
  "POST",
  { headers: { "Content-Type": "application/json" } },
  { name: "John" }
).run();

Parameters

path: string
  • The request path, relative to baseUrl if configured.
method: Method
  • The HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS).
optional
options: RequestOptions
  • Request-specific options that override client defaults.
optional
body: unknown
  • Request body for POST, PUT, PATCH requests.

Return Type

A Task that resolves with the response or rejects with an HttpError.

Usage

import { WebClient } from ".";