function expectOk
expectOk<T>(res: Response): Promise<T>

Returns the payload of res. In a form, the error it throws reaches useApiForm's submit, which shows it as the form's error.

Type Parameters

Parameters

Return Type

Promise<T>

Throws

Error

With the server's message when the response says success: false, and when the body isn't JSON or isn't an envelope.

Usage

import { expectOk } from "src/utils/shared/api.ts";