Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.clone() returns a new instance but can not produce .handler() #206

Closed
BounSweFerhatSal opened this issue Jul 21, 2022 · 2 comments · Fixed by #207
Closed

.clone() returns a new instance but can not produce .handler() #206

BounSweFerhatSal opened this issue Jul 21, 2022 · 2 comments · Fixed by #207

Comments

@BounSweFerhatSal
Copy link

when creating a router as below in a separate file , to use as a base as below :

import { createRouter } from "next-connect";

const pipeLineRouter = createRouter();
export default pipeLineRouter
  .use(jwtTokenValidator_middleware)
  .use(dbConnection_middleware);

then importing in another API file by cloning the router as below (as suggested) :

import apiPipeline from "/lib/apiPipeline";

const router = apiPipeline.clone();
router.get(async (req, res) => {
    //......
});

export default router.handler(errorCather);

router.handler() fails with error :

TypeError: router.handler is not a function

However, console.log(router) gives exact same router object properties which has been cloned.

@hoangvvo
Copy link
Owner

This is a bug, I am fixing it right now

@hoangvvo
Copy link
Owner

This is fixed in latest next version. Let me know if you still face it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants