'mvc controller returning error res.status is not a function

my controller file is giving me an error when using the code below. it says res.status is not a function.

does anyone know what the issue could be? It works if I put the function directly in my routes file.

let User = require("../models/user.model");

function getAll (res, req) {
    User.find()
    .then(user => res.json(user))
    .catch(err => res.status(400).json("Error: " + err));
}


Solution 1:[1]

This is becuase you flipped the parameters for the function, and I assume you're passing them normally where you call this function. It should be req, res

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexandru DuDu