POST()function

POST(path: AbsolutePath, payload?: Schema<P>, result?: Schema<R>): Endpoint<P, R>
POST(path: AbsolutePath, payload: Schema<P>): Endpoint<P, undefined>
POST(path: AbsolutePath, payload: undefined, result: Schema<R>): Endpoint<undefined, R>
ParamType
pathAbsolutePath
The endpoint path, possibly including {placeholders} required
payloadSchema<P>
An optional Schema validating the request payload.
resultSchema<R>
An optional Schema validating the response result.
pathAbsolutePath
Absolute path string starting with a / slash. required
payloadSchema<P>
Schema is an object instance with a validate() method that converts unknown input into a known, valid type T. required
payloadundefined
required
resultSchema<R>
Schema is an object instance with a validate() method that converts unknown input into a known, valid type T. required
Return
Endpoint<P, R>
An Endpoint configured for the POST method.
Endpoint<P, undefined>
A typed API resource definition pairing a method and path with payload and result schemas.
Endpoint<undefined, R>
A typed API resource definition pairing a method and path with payload and result schemas.

Define a POST endpoint at a path, with validated payload and result types.

  • "The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server."

    Factory for Endpoint.

Examples

POST("/users", USER, USER_RESULT)