![](/img/trans.png)
[英]Fastify with TypeScript, How to validate and type a routes request?
[英]fastify route request and response handler type in Typescript
有人知道 fastify 中的請求和響應處理程序類型是什么嗎?
現在我只是使用“任何”,打字稿 eslint 給了我一個警告:
fastify.post('/ac', async(req: any , res: any) => {
您正在尋找的適當類型分別是“FastifyRequest”和“FastifyReply”。
它們可以被導入和實現,如下所示。
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
fastify.post('/ac', async (req: FastifyRequest, res: FastifyReply) => {
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.