parseRequestJSON()function

parseRequestJSON(request: Request, caller: AnyCaller = parseRequestJSON): Promise<unknown>
ParamType
requestRequest
The Request whose JSON body to parse. required
callerAnyCaller
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);