Search code examples
expresserror-handlingmern

Why am I getting error in this express.js code?


[code for app.js](h[code for authorize.jsthe error which I'm getting](https://i.sstatic.net/g9KrB.png)ttps://i.sstatic.net/Srqvp.png)

This is about page, so I was expecting to get About page in my screen when the url was http://localhost:5000/about?user=jiwan note: I'm learning mern


Solution

  • You are setting the user object on the req.

    Please set it on the response(If that's what you want).

    Other than that, it's because jiwan should be a string.

    So

    if(user == 'jiwan'){
       res.user = {name:'jiwan', id: 1}
       next()
    }