Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.route('/cheeses/:id')
- .get(controller.showRoute)
- export function showRoute(req: Request, res: Response, next: NextFunction): void {
- Cheese.findById(req.params.id)
- .then((cheese: ICheeseModel) => res.json(cheese))
- .catch(next)
- }
- lib/controllers/cheeses.ts:11:30 - error TS2339: Property 'id' does not exist on type 'Params'.
- Property 'id' does not exist on type 'string[]'.
- 11 Cheese.findById(req.params.id)
- ~~
- {
- "compilerOptions": {
- "module": "commonjs",
- "moduleResolution": "node",
- "pretty": true,
- "sourceMap": true,
- "target": "es6",
- "outDir": "./dist",
- "baseUrl": "./lib"
- },
- "include": [
- "lib/**/*.ts"
- ],
- "exclude": [
- "node_modules"
- ]
- }
- {
- "name": "typescript-express-api",
- "version": "1.0.0",
- "main": "index.js",
- "license": "MIT",
- "scripts": {
- "build": "tsc",
- "dev": "nodemon",
- "start": "node ./dist/server"
- },
- "dependencies": {
- "@types/express": "^4.17.0",
- "@types/mongoose": "^5.5.12",
- "@types/node": "^12.7.2",
- "@types/webrtc": "^0.0.25",
- "express": "^4.17.1",
- "mongoose": "^5.6.9",
- "ts-node": "^8.3.0",
- "typescript": "^3.5.3"
- }
- }
- {
- "watch": ["lib"],
- "ext": "ts",
- "exec": "ts-node ./lib/app.ts"
- }
- declare namespace Express {
- export interface Request {
- params: any;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement