title: how to fix 'Error: TypeError: Cannot read property 'catch' of undefined ' when saving a user
body: <p>There are a user model and the app.js,</p>
  
  <p>in app.js we have a catch for the <strong>user.save()</strong> that throws the error in the console:</p>
  
  <pre><code>TypeError: Cannot read property 'catch' of undefined 
  </code></pre>
  
  <p>user model :</p>
  
  <pre><code>const Schema = mongoose.Schema
  
  const UserSchema = new Schema({
      email: {
          type: String,
          required: true,
          unique: true,
          trim: true,
          minLength: 3        
      },
      password: {
          type: String,
          required: true,
          minLength: 5
      }
  
  })
  
  module.exports = mongoose.model( 'users', UserSchema )
  </code></pre>
  
  <p>app.js file :</p>
  
  <pre><code>const mongoose = require( 'mongoose')
  mongoose.Promise = global.Promise
  
  const bcrypt = require( 'bcryptjs')
  const User = require('./models/User')
  const express = require('express')
  const app = express()
  
  const bodyParser = require('body-parser')
  app.use(bodyParser.json())
  app.use(bodyParser.urlencoded({ extended: true }))
  
  
  
  app.listen( 4111, () =&gt; {
      console.log( 'listening on 4111 ...' )
  })
  
  mongoose.connect( 'mongodb://127.0.0.1/login', () =&gt; {
      console.log( 'Connected ! ')
  })
  
  app.post('/register', ( req, res ) =&gt; {
      let newUser = new User()
      newUser.email = req.body.email || 'gmail'
      newUser.password = req.body.password || 1234
      // res.send( newUser )
      bcrypt.genSalt( 10,  salt =&gt; {
          bcrypt.hash( req.body.password, salt, ( err, hash ) =&gt; {
              if( err ) return err 
              newUser.password = hash
              newUser.save().then( savedUser =&gt; {
                  res.send( 'The user saved: ', savedUser )
               }).catch( (err) =&gt; {
                  res.send( 'The user was not saved : ', err )
              })
          })
      } ).catch( err =&gt; {
          res.send( 'gen salt err :', err )
      })
  })
  
  </code></pre>
  
  <p>I saw some similar question here but were not the same as this one.</p>