课程: React: Creating and Hosting a Full-Stack Site
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Making requests with auth tokens - React.js教程
课程: React: Creating and Hosting a Full-Stack Site
Making requests with auth tokens
- [Instructor] Well now that we've protected our endpoints and there are actually a few adjustments that we'll need to make to this code before it will work properly, but we'll get to those a little bit later. The next thing that we're going to do is we need our front end to actually send along this authtoken when it makes a request to one of these endpoints. So what we're going to do here is we're going to open up our ArticlePage, and this has functionality for both upvoting and adding a comment. So inside here, we just need to have access to the user that's currently logged in and send that user's authtoken along with whatever requests we make. So here's what this is going to look like. We're going to say import useUser from, and then we're going to say dot dot slash useUser. And now that we have that, we're going to add that hook to this article page component by saying, const user. Well here, we'll need isLoading first of all, and then user equals useUser. So now we have access to…
内容
-
-
-
-
-
-
-
(已锁定)
Why Firebase Auth?2 分钟 9 秒
-
(已锁定)
Creating a Firebase project1 分钟 43 秒
-
(已锁定)
Adding Firebase Auth to React6 分钟 7 秒
-
(已锁定)
Build a login form8 分钟 51 秒
-
(已锁定)
Build a create account page7 分钟 23 秒
-
(已锁定)
Making interface adjustments for authenticated users6 分钟 8 秒
-
(已锁定)
Creating a custom auth hook9 分钟 3 秒
-
(已锁定)
Adding Firebase Auth to Node.js6 分钟 35 秒
-
(已锁定)
Protecting endpoints using auth tokens4 分钟 33 秒
-
(已锁定)
Protecting the upvote and comment endpoints5 分钟 7 秒
-
(已锁定)
Making requests with auth tokens7 分钟 7 秒
-
(已锁定)
-
-