From the course: Node.js: Microservices
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Make the front end use JWT authentication - Node.js Tutorial
From the course: Node.js: Microservices
Make the front end use JWT authentication
- [Instructor] Let's now change our shop application, so that it can use this token. For that I open workspace, shopper, server, routes, user, index js, and there you have this login route. And as we learned before, we will now get a token back and not an authenticated user. So, the token will contain this user, but it will be embedded into the token payload. The first thing I'm going to do is I will also here add a Try Catch block. So, let's leave the code in a better shape always when you change something. So, I add catch, Try Catch, and I will move the function block right into the try block. And if an error happens, I will do pretty much the same as I do up here. So, I will copy now an error message down here, so that if something happens, I will, console, error, the error so that I myself know what's happening. And then, I will let the user know that something went wrong and let's call it something went wrong.…