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