Bad Request (400) Error on Page Load
I notice an error in my console on initial page load that relates to the check for a logged in user in app/public/js/lib/app.js, e.g.
// as the app spins up, let's check to see if
// we have an active session with the server
$http.get('/user')
.success(function (data) {
$rootScope.user.username = data.username;
})
.error(function (data) {
});
This is effective, but I wonder if there is a more elegant way to handle the response without generating an error on the client. I made a few attempts, but I couldn't get it to work without interfering with how the authentication scheme works (I am not that experienced).
Any ideas on an approach to fix?
I'm open to suggestions, but this brings up an interesting point. The word "error" has somewhat negative connotations, however in this case I feel like it is fairly expressive. By asking the server a question ("Who am I?"), and getting back a 400 error, you are certainly getting a definitive answer ("No one!"). Further more, you can use this error to trigger events, similar to how the redirect to login event is triggered by a 401 error.
I'm not super experienced in design decisions like this either, and would welcome any advice. Leaving this issue open for a while if anyone else wants to chime in.