Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

245
Views
No overload matches this call.The last overload gave the following error. while writing firebase functions using Typescript

No overload matches this call.The last overload gave the following error. This is the error i get from the firebase functions

i wrote a code for the closed endpoints to privilege the routes, up to middleware everything is working fine but when i try to use that endpoint the error is coming.

Error Message:

No overload matches this call. The last overload gave the following error. Argument of type '(req: User, res: express.Response, next: express.NextFunction) => express.Response | Promise<void | express.Response>' is not assignable to parameter of type 'PathParams'.

This is my code


//controller.ts file
import { ProductModel } from "./model";
import * as express from "express";
import { endPoint } from "../../helpers/endpoint";
import { isAdmin } from "../../middlewares/middlewares";

const router = express.Router();

router
  .use(endPoint, isAdmin)
  .post("/admin/addProduct", (req: any, res: express.Response) => {
    const obj = new ProductModel(req.user);

    obj
      ._create_product(req.body)
      .then(() => {
        return res
          .status(201)
          .json({ message: "New Product created successfully" });
      })
      .catch((err) => {
        return res.status(404).json({ error: "Failed to create product", err });
      });
  });

export default router;

 //endpoint.ts file

import { admin, db } from "../config/admin";
import * as express from "express";

interface User extends express.Request{
  user:{
    email:string,
    uid:string
  }
}
export const endPoint = (
  req:User,
  res: express.Response,
  next: express.NextFunction
) => {
  if (!req.headers && !req.headers["authorization"]) {
    return res.status(404).json({ error: "UnAuthorised" });
  } else {
    const bearer: any = req.headers["authorization"];
    const token: any = bearer.split("Bearer ")[1];
    return admin
      .auth()
      .verifyIdToken(token)
      .then((decoded) => {
        console.log("decoded",decoded);
        req.user.uid=decoded.uid
        console.log("req.user",req.user.uid)
        return db
          .collection("USERS")
          .where("uid", "==", req.user)
          .limit(1)
          .get();
      })
      .then((userData) => {
        console.log(userData)
        req.user.email= userData.docs[0].data().email
        return next();
      })
      .catch((error) => {
        console.error(error);
        if (error.code === "auth/id-token-expired") {
          return res.status(401).json({
            message: `Token has expired please try again!!! with new Token`,
          });
        }
        return res.status(500).json({ message: `invalid token` });
      });
  }
};
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!