title: Cannot set property statusCode of undefined
body: <p>I'm trying to create a backend to my application and i'm actually writing the route login for the users but I encounter a error when I test the route with Postman, this error is : </p>
  
  <blockquote>
    <p>UnhandledPromiseRejectionWarning: TypeError: Cannot set property
    'statusCode' of undefined</p>
  </blockquote>
  
  <p>at the line </p>
  
  <blockquote>
    <p>this.response.statusCode = 401</p>
  </blockquote>
  
  <p>Here my code : </p>
  
  <pre><code>import Rider from '../../models/riders'
  import jwt from 'jsonwebtoken'
  
  export default class LoginService {
  /**
   * @param {String} email
   * @param {String} password 
   * */
  constructor(email, password) {
      this.email = email
      this.password = password
  
      this.reponse = {
          statusCode: 200,
          responseData: {},
      }
  }
  
  loginRider() {
      return new Promise((resolve) =&gt; {
          this.checkIdentifiant()
            .then((r) =&gt; {
              // identifiant correct, l'user peut se connecter
              console.log(r)
              console.log("apres then apres checkidentifiant")
              this.response.responseData = {
                token: jwt.sign(r.toJSON(), process.env.TOKEN_PASSWORD),
              }
              resolve(this.response)
            })
            .catch((e) =&gt; {
              console.log("dans le catch login rider")
              console.log(e)
              // erreur lors de l'authentification / error code unauthorized 401
              this.response.statusCode = 401
              this.response.responseData = {
                error: 'unauthorized',
                error_description: 'Identifiants incorrect',
              }
  
              // On log l'erreur dans la console pour l'admin
              resolve(this.response)
            })
        })
  }
  
  /**
  * Vérifie le mot de passe et l'email de l'user qui tente de se connecter
  *
  * @returns {boolean}
  */
  checkIdentifiant() {
  // on cherche un livreur ayant le même mail que celui fourni dans la BDD
  return new Promise((resolve, reject) =&gt; {
    Rider.findOne({ email: this.email, password: this.password }, (err, rider) =&gt; {
      if (err || !rider) {
        console.log("identifiant invalide dans le checkidentifiant")
        reject()
      }
      // si le rider est trouvé dans la BDD
      if (rider) {
        console.log("identifiant correct, dans le check identifiant")
        // pas sécurisé, à améliorer
        resolve(rider)
      }
    })
  })
  }
  }
  </code></pre>
  
  <p>The console.log I put show me that I run in the block catch of LoginRider.</p>
  
  <p>I use nodeJS and expressJS to write my backend and my database use MongoDB. Postman is used for testing the API</p>