Home > front end >  "No overload matches this call"
"No overload matches this call"

Time:02-01

I'm currently working on a project for college and i dont know what this message mean i'm trying to make an API that reads as .csv file and stores it data on a data bank using insomnia but i dont know how to fix that.

No overload matches this call. The last overload gave the following error. Argument of type '(request: Request, response: Response) => any' is not assignable to parameter of type 'RequestHandlerParams<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'. Type '(request: Request, response: Response) => any' is not assignable to type 'RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'. Types of parameters 'request' and 'req' are incompatible. Type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is missing the following properties from type 'Request': cache, credentials, destination, integrity, and 13 more.

import { Router } from "express";

import multer from "multer";

const multerConfig = multer();

const router = Router();

router.post("/products", multerConfig.single("file"), (request: Request, response: Response)=>{
console.log(request.file);
    return response.send();
})

export {router};

CodePudding user response:

I believe you should just need to update your types and import the types from Express.

import { Router, Request, Response } from 'express';

Since right now you are using Fetch API types.

  •  Tags:  
  • Related