@barry-rocks/sdk/http
Small HTTP client helpers: postJson and describeFetchFailure, which turns
a failed fetch into a message that says what went wrong.
import { … } from "@barry-rocks/sdk/http";Interfaces
Section titled “Interfaces”JsonRequest
Section titled “JsonRequest”Properties
Section titled “Properties”Functions
Section titled “Functions”describeFetchFailure()
Section titled “describeFetchFailure()”describeFetchFailure(
err,url,timeoutMs):string
Classify the wrapper’s abort as timeout, verified connection failures as unreachable, and other fetch errors without inventing a cause. See docs/decisions/0011-sdk-runtime-invariants.md for the retained rationale.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
err |
unknown |
url |
string |
timeoutMs |
number |
Returns
Section titled “Returns”string
postJson()
Section titled “postJson()”postJson<
T>(opts):Promise<T>
POST JSON and parse the reply, with one timeout and honest failure attribution.
Every vendor speaks HTTP+JSON, and each one had grown its own AbortController/timer/try-catch. The duplication is not just lines: it is three chances to get the diagnostic wrong in different ways.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts |
JsonRequest |
Returns
Section titled “Returns”Promise<T>