Res.json(users) is not working, I need your help!

exports.allUsers = (req,res) => {
  User.find((err, users) => {
    if (err){
      return res.status(400).json({
        error: err
    res.json(users);     ## This Line
  }).select("name email updated created")

As I have mentioned Link…when I write res.json({users}) it is giving me /users 400 status code and while writing res.json(users) it is giving me /users 304 status code.

Currently I am using react + node js as backend with MongoDB as database and want to use map function. But it is not working in class. So, I have tried to respond soon not as an object…

Now it is giving me error, Can someone help me out!

Should we add return before res.json(users) ?