parseRequestJSON()function
parseRequestJSON(request: Request, caller: AnyCaller = parseRequestJSON): Promise<unknown>
| Param | Type | |
|---|---|---|
request | Request | The Request whose JSON body to parse. required |
caller | AnyCaller | Identity of the calling function for error attribution. Defaults to parseRequestJSON |
| Return | |
|---|---|
Promise<unknown> | The parsed JSON value, or undefined if the body is empty. |
| Throws | |
|---|---|
RequestError | If the request body is not valid JSON. |
Parse JSON from an HTTP Request, or return undefined when the request has no body.
Examples
const data = await parseRequestJSON(request);