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

UnhandledPromiseRejectionWarning: TypeError: versionRouter.route is not a function #59

Closed
arvindgemini opened this issue May 28, 2021 · 2 comments
Labels

Comments

@arvindgemini
Copy link

Getting exception error, added sample code only

import * as versionRouter from 'express-version-route';
import { Router, Handler, Request, Response } from 'express';
const routesMap = new Map<string, Handler>();
const route = Router();

export default (app: Router) => {
app.use('/version-customer', route);

routesMap.set('1.0', (req, res, next) => {
return res.status(200).json({ message: 'hello to you version 1.0' });
});

routesMap.set('default', (req, res, next) => {
return res.status(200).json({ message: 'hello to you, this is the default route' });
});

route.get('/test', versionRouter.route(routesMap));
};

@lirantal
Copy link
Owner

I think you're not importing it correctly.
What if you try the following import?

import versionRouter from 'express-version-route';

@arvindgemini
Copy link
Author

Thanks @LiranBri types were missing which causing the issue.

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

No branches or pull requests

2 participants