title: CastError: Cast to ObjectId failed for value "favicon.ico" at path "_id" for model
body: <p>I am learning how to make a node api with the help of a youtube tutorial but I get this error everytime when I run nodemon and go to the localhost. I haven't use nay favicon.ico in any part of my code. Can someone help me?</p>
  
  <p>This is my full code for the movies model</p>
  
  <pre><code>var mongoose = require('mongoose');
  
  //movie schema
  var moviesSchema = mongoose.Schema({
     Title: {
         type: String,
         required: true
     },
      Genre: {
          type: String,
          required: true
      },
      Release: {
          type: String,
          required: true
      },
      Director: {
          type: String,
          required: true
      },
      Stars: {
          type: String,
          required: true
      },
      Summary: {
          type: String,
          required: true
      }
  });
  
  //export the schema
  var Movies = module.exports = mongoose.model('Movies',moviesSchema);
  
  //get movies
  module.exports.getMovies = function(callback, limit){
      Movies.find(callback).limit(limit);
  };
  
  //get movies by id
  module.exports.getMovieById = function(id, callback){
      Movies.findById(id, callback);
  };
  
  //add a movie
  module.exports.addMovie = function(movie, callback){
      Movies.create(movie, callback);
  };
  
  //update a movie
  module.exports.updateMovie = function(id, movie, options, callback){
      var query = {_id:id};
      var update = {
          Title : movie.Title,
          Genre : movie.Genre,
          Release : movie.Release,
          Director : movie.Director,
          Stars : movie.Stars,
          Summary : movie.Summary
  
  
      };
      Movies.findOneAndUpdate(query, update, options, callback);
  };
  
  //delete a movie
  module.exports.deleteMovie = function(id, callback){
      var query = {_id:id};
      Movies.remove(query, callback);
  };
  </code></pre>
  
  <p>This is my index.js</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require("body-parser");
  var mongoose = require('mongoose');
  
  Movie = require('./models/movies');
  
  var app = express();
  
  app.use(bodyParser.json());
  
  //mongoose connection
  mongoose.connect('mongodb://localhost/movielist');
  var db = mongoose.connection;
  
  //get all movies json format
  app.get('/',function(req,res){
      Movie.getMovies(function(err,movies){
          if(err){
              throw err;
          }
          res.json(movies);
      });
  });
  
  //get movie by id
  app.get('/:_id',function(req,res){
      Movie.getMovieById(req.params._id, function(err,movie){
          if(err){
              throw err;
          }
          res.json(movie);
      });
  });
  
  //post new movies
  app.post('/',function(req,res){
      var movies = req.body;
      Movie.addMovie(movies,function(err,movies){
          if(err){
              throw err;
          }
          res.json(movies);
      });
  });
  
  //update new movies
  app.put('/:_id',function(req,res){
      var id = req.params._id;
      var movies = req.body;
      Movie.updateMovie(id, movies, {}, function(err,movies){
          if(err){
              throw err;
          }
          res.json(movies);
      });
  });
  
  //delete an existing movie
  app.delete('/:_id',function(req,res){
      var id = req.params._id;
      Movie.deleteMovie(id, function(err,movies){
          if(err){
              throw err;
          }
          res.json(movies);
      });
  });
  
  app.listen(8000);
  console.log("running on port 8000");
  </code></pre>
  
  <p>From what I can see in the console log is that the error might be from this code</p>
  
  <pre><code>   //get movies by id
  module.exports.getMovieById = function(id, callback){
      Movies.findById(id, callback);
  };
  </code></pre>
  
  <p>and in the index.js from this code</p>
  
  <pre><code>Movie.getMovieById(req.params._id, function(err,movie){
  </code></pre>
  
  <p>But I dont understand that favicon.ico failure</p>