app.apiCall
The apiCall
method is used to define routes that perform API calls. This allows for the creation and handling of routes that interact with the server and return data in JSON format or another format supported by the API.
Method Signature
apiCall<Handler extends ApiCallRouteHandlerFn>(
pattern: string,
handler: Handler,
): ApiCallRouteRef<Handler extends ApiCallRouteHandlerFn<infer Body> ? Body : never, GetReturnTypeOfHandler<Handler>>
Parameters
-
pattern:
string
The route path that should be handled by this route. This is a string that defines the URL that this route will respond to. -
handler:
Handler
The route handler function that performs the main logic for processing the request and returning data. The typeHandler
extendsApiCallRouteHandlerFn
.
Return Value ApiCallRouteRef
Returns a reference to the route, which includes methods for executing this route. The type of the return value depends on the type of the handler function used in the route.