title: Display React properties by Id
body: <p>I have multiples projects and I can't show each one properties in each project page by its ID.
  (Using Nodejs, Reactjs, MongoDB...)
  it gives an error</p>
  
  <blockquote>
    <p>Cast to ObjectId failed for value ":id" at path "_id" for model "project"</p>
  </blockquote>
  
  <p>and this console.log :</p>
  
  <pre><code>console.log('-----------PROJECTS byId-----------', projects);
  </code></pre>
  
  <p>gives me <code>undefined</code></p>
  
  <p>My routes:</p>
  
  <pre><code>const express = require('express'),
  Projects = require('../models/projects.js'),
  app = express.Router();
  exports.render_projects_byId = (req, res) =&gt; {
  let id = req.params.id;
  
  Projects.findById(id).exec((err, projects) =&gt; {
      if (err) {
          console.log(err);
      }
      console.log('-----------PROJECTS byId-----------', projects);
      res.json(projects)
    });
  };
  </code></pre>
  
  <p>My Project Page that will appear project properties by it's own ID</p>
  
  <pre><code>import React, { Component } from 'react';
  import { NavLink } from 'react-router-dom';
  
  import './Project.css';
  
  
  
  class Project extends Component {
      state = {
       title : '',
       typeOfProduction: ''
      };
  
  componentDidMount() {
  
      fetch('/dashboard/projects/:id')
      .then(response =&gt; { return response.json()
          .then(projects =&gt; {
              console.log(projects);
              this.setState({
                  title: this.state.title,
                  typeOfProduction: this.state.typeOfProduction
              })      
          })
      }).catch(error =&gt; console.error('Error:', error));
  }
  
  render() {
   console.log("This.state.projects " + this.state.projects);
  
      return (
  
          &lt;div&gt;
              &lt;section className="Project container"&gt;
                    &lt;h1&gt;
                    {this.state.title} oi
                    &lt;/h1&gt;
                    &lt;h1&gt;
                    {this.state.typeOfProduction} oi
                    &lt;/h1&gt;
              &lt;/section&gt;
          &lt;/div&gt;
      );
  
      }
  }
  
  export default Project;
  </code></pre>
  
  <p>My Project models Schema:</p>
  
  <pre><code>var mongoose = require("mongoose");
  
  var projectSchema = new mongoose.Schema({
  
     title: String,
     typeOfProduction: String
  })
  
  module.exports = mongoose.model("Projects", projectSchema);
  </code></pre>