课程: React: Authentication

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Adding a sign-up route to the server

Adding a sign-up route to the server - React.js教程

课程: React: Authentication

Adding a sign-up route to the server

- [Instructor] Now that we know the basics behind what JSON Web Tokens are and how they work, it's time to start adding some routes to our server that'll incorporate JWTs as a way to allow us to sign up users and log them in. First thing we're going to add to our server is a sign up route. So let's open up our backend and src and routes here. That's where we'll be creating it. And this is the route that our server will send a request to when a new user signs up and what the route'll do is it's basically going to create a new user in our database and send back a JSON Web Token containing the user's data. We'll see a little later on exactly how this is actually stored and used by the front end but for now, here's what it's going to look like. Let's start off by creating a new file for our route. And we'll just call it signUpRoute.js. And just like we defined our testRoute using this object, we're going to use the same…

内容