title: Cannot GET :id route findById() express
body: <p>I cannot <code>GET</code> data (with Insomnia) from my collection with an specific <code>id</code>. Below is an example request URL.</p>
  
  <p><code>http://localhost:5000/todos/5dd295a49d5d7a0b7a399bbe</code></p>
  
  <p>But when I <a href="http://localhost:5000/todos/" rel="nofollow noreferrer">http://localhost:5000/todos/</a>. without the <code>id</code> I can display all the data inside the collection.</p>
  
  <p>Here is my code :</p>
  
  <ul>
  <li>Todos route :</li>
  </ul>
  
  <pre><code>const router = require('express').Router();
  let Todo = require('../models/todo.model');
  
  router.route('/').get((req, res) =&gt; {
    Todo.find()
      .then(todos =&gt; res.json(todos))
      .catch(err =&gt; res.status(400).json('Error: ' + err));
  });
  
  router.route('/add').post((req, res) =&gt; {
    const title = req.body.title;
    const description = req.body.description;
    const date = Date.parse(req.body.date);
  
    const newTodo = new Todo({
      title,
      description,
      date
    });
  
    router.route('/:id').get((req, res) =&gt; {
      Todo.findById(req.params.id)
        .then(todo =&gt; res.json(todo))
        .catch(err =&gt; res.status(400).json('The fuck is the Error: ' + err));
    });
  
    router.route('/:id').delete((req, res) =&gt; {
      Todo.findByIdAndDelete(req.params.id)
        .then(() =&gt; res.json('Todo deleted.'))
        .catch(err =&gt; res.status(400).json('Error: ' + err));
    });
  
    router.route('/update/:id').post((req, res) =&gt; {
      Todo.findById(req.params.id)
        .then(todo =&gt; {
          todo.username = req.body.username;
          todo.description = req.body.description;
          todo.duration = Number(req.body.duration);
          todo.date = Date.parse(req.body.date);
  
          todo.save()
            .then(() =&gt; res.json('Todo updated!'))
            .catch(err =&gt; res.status(400).json('Error: ' + err));
        })
        .catch(err =&gt; res.status(400).json('Error: ' + err));
    });
  
    newTodo.save()
      .then(() =&gt; res.json('Todo added!'))
      .catch(err =&gt; res.status(400).json('Error: ' + err));
  });
  
  module.exports = router;
  </code></pre>
  
  <ul>
  <li>server.js :</li>
  </ul>
  
  <pre><code>const express = require('express');
  const cors = require('cors');
  const mongoose = require('mongoose') // connect to mongoDATABASE
  
  require('dotenv').config();
  
  const app = express();
  const port = process.env.PORT || 5000;
  
  app.use(cors());
  app.use(express.json());
  
  const uri = process.env.ATLAS_URI;
  mongoose.connect(
      uri, {
      useNewUrlParser: true, 
      useCreateIndex: true,
      useUnifiedTopology: true
  } // always put those
  );
  
  const connection = mongoose.connection;
  connection.once('open', () =&gt; {
    console.log("MongoDB database connection established successfully");
  })
  
  const todosRouter = require('./routes/todos');
  
  app.use('/todos', todosRouter);
  
  app.listen(port, () =&gt; {
      console.log(`Server is running on port: ${port}`);
  });
  </code></pre>