Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

247
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda