app.post
The post method is used to create a POST
route in the application. It takes a URL pattern and a handler that will be invoked when a POST request is received at the specified pattern.
Signature
post<Handler extends CustomRouteHandlerFn>(
pattern: string,
handler: Handler,
): PostRouteRef<Handler extends CustomRouteHandlerFn<infer Body> ? Body : never, GetReturnTypeOfHandler<Handler>>
Parameters
-
pattern:
string
The URL pattern that must match the request URL for the handler to be invoked. -
handler:
Handler
The handler function that will be called upon receiving a POST request at the specified URL pattern. The handler must conform to the type CustomRouteHandlerFn.
Return Value PostRouteRef
An object PostRouteRef
, which represents a reference to the created route. This object can be used for further interaction with the route, such as navigation or execution.