类型参数不可分配给类型 'MiddlewareFunc' 的参数。 app.use(oakCors());
Argument of type is not assignable to parameter of type 'MiddlewareFunc'. app.use(oakCors());
当我尝试在 deno 中添加 cors 时出现此错误。
'(context: { request: any; response: any; }, next: (...args: any) => any) => any' 类型的参数不可分配给 'MiddlewareFunc'。
app.use(oakCors());
import { Application } from "https://deno.land/x/abc@v1.0.0-rc8/mod.ts";
import { getAllBlogs, getBlogById, addNewBlog } from './controllers/index.ts';
import { oakCors } from "https://deno.land/x/cors/mod.ts";
const app = new Application();
app
.use(oakCors())
.get('/blogs', getAllBlogs)
.get('/blog/:id', getBlogById)
.post('/add-blog', addNewBlog)
.start({ port: 8000 })
Error Image
cors
为不同的框架导出中间件,你应该为 abc
使用 abcCors
而不是 Oak
.[=16= 的 oakCors
]
import { abcCors } from "https://deno.land/x/cors/mod.ts";
当我尝试在 deno 中添加 cors 时出现此错误。
'(context: { request: any; response: any; }, next: (...args: any) => any) => any' 类型的参数不可分配给 'MiddlewareFunc'。 app.use(oakCors());
import { Application } from "https://deno.land/x/abc@v1.0.0-rc8/mod.ts";
import { getAllBlogs, getBlogById, addNewBlog } from './controllers/index.ts';
import { oakCors } from "https://deno.land/x/cors/mod.ts";
const app = new Application();
app
.use(oakCors())
.get('/blogs', getAllBlogs)
.get('/blog/:id', getBlogById)
.post('/add-blog', addNewBlog)
.start({ port: 8000 })
Error Image
cors
为不同的框架导出中间件,你应该为 abc
使用 abcCors
而不是 Oak
.[=16= 的 oakCors
]
import { abcCors } from "https://deno.land/x/cors/mod.ts";