Bug in users.controller.js

Hi,
I’m trying to logout manually in the mflix website and I’m getting this error:
POST http://localhost:5000/api/v1/user/logout 500 (Internal Server Error)

TypeError: Cannot read property 'slice' of undefined
    at _callee6$ (mflix-js/src/api/users.controller.js:123:23)
    at tryCatch (mflix-js/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (mflix-js/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (mflix-js/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12
    at logout (mflix-js/src/api/users.controller.js:457:24)
POST /api/v1/user/logout 500 24.119 ms - 2

the code in these lines is:

  static async logout(req, res) {
    try {
      ---> const userJwt = req.get("Authorization").slice("Bearer ".length)
      const userObj = await User.decoded(userJwt)

(btw, I’m getting a similar error when trying to add new comment.)
Does anyone have an idea how to fix it?
Thanks,
Rafael,

1 Like

Hey Rafael,
have you solved the problem??

Hi @Adeeb_Akhtar ,
As far as I can remember, I just continued with the course without solving this problem.
I think you can skip it and finish the course (get 100% score) without solving this issue.
Good luck,
Rafael,