NodeJS returning JSON, but not to client properly

NodeJS returning JSON, but not to client properly

So, I have a route that is authing a user based on username and password input. The first validation check, I just can't seem to get to work:

So, I have a route that is authing a user based on username and password input. The first validation check, I just can't seem to get to work:

exports.user_login = (req, res, next) => {
    passport.authenticate('local', { session: false }, (err, user, info) => {
        if (err || !user) {
            res.status(500).json({
                errorMsg: "User could not be authenticated."
            });
        }

If I ping this via postman, I get the appropriate JSON response back that the User could not be authenticated.

However, if I use this route from my client-side code, and try to console.log it, or whatever else (essentially, I want to pull whatever the errorMsg is, log it in state, and reflect that back to the user), then I just get the following response:

axios.post("api/auth/login/", user)
            .then(res => {
                console.log(res);
                this.setState({
                    username: "",
                    password: ""
                })
                localStorage.setItem('bdgt', res.data.token);
            })
            .catch(err => {
                console.log(err);

        })

I've looked at other code I've done before, and usually this works, and I can typically access the message and store it to state by:

this.setState({
     error: err.errorMsg
})

Thoughts? What am I missing?

EDIT ... If I just let it do res.json({ errorMsg: "message....."}) ... this works just fine, but returns a 200 which is obviously not what I want.

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

Build a REST API using Node.js, Express.js, Mongoose.js and MongoDB

Node.js, Express.js, Mongoose.js, and MongoDB is a great combination for building easy and fast REST API. You will see how fast that combination than other existing frameworks because of Node.js is a packaged compilation of Google’s V8 JavaScript engine and it works on non-blocking and event-driven I/O. Express.js is a Javascript web server that has a complete function of web development including REST API.