Skip to content

Function: ensureJsonContentType() ​

ensureJsonContentType(request): void

Defined in: index.ts:71

Validates that the request has a JSON content type. Throws InvalidContentTypeError if the content type is not application/json.

Parameters ​

request ​

Request

The HTTP request to validate

Returns ​

void

Throws ​

InvalidContentTypeError if Content-Type is not application/json

Example ​

typescript
ensureJsonContentType(request);
const body = await parseJsonBody(request);