React User Login and Authentication with Axios

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
    Create a React User Login and Authentication form with Axios request submission. We'll build a user login form and submit the username and password with Axios to a backend REST API for authentication.
    💖 Support me on Patreon ➜ / davegray
    ⭐ Become a full-stack web dev with Zero To Mastery Courses:
    - Advanced React: bit.ly/AdvReactDev
    - Jr to Senior Web Dev Roadmap: bit.ly/WebDevRoadmap-JrtoSr
    - Master FAANG Coding Interviews: bit.ly/FAANGInterview
    🚩 Subscribe ➜ bit.ly/3nGHmNn
    🚀 React JS for Beginners full course - 9 hours: • React JS Full Course f...
    👀 React Login tutorial series playlist: • React Login, Registrat...
    🔗 Source Code: github.com/gitdagray/react_lo...
    📬 Course Updates ➜ courses.davegray.codes/
    React User Login and Authentication with Axios
    (00:00) Intro
    (00:18) Welcome
    (00:49) Starting App State
    (01:30) Create the Login component
    (02:12) Adding React Hooks
    (04:22) Starting the JSX
    (05:24) Username Input
    (08:19) Password Input
    (09:22) Finish the form
    (10:18) handleSubmit function
    (12:03) Displaying the success screen
    (12:59) Testing the form
    (13:57) Creating Auth context and state
    (18:09) Adding Axios to the project
    (20:01) Adding Axios to handleSubmit
    (25:11) Handling Errors
    (27:10) Node JS Authentication server
    (28:55) Testing Server Responses
    ☕ Buy Me A Coffee: www.buymeacoffee.com/davegray
    🔗 React Register Form with Validation, Axios and a11y: • React JS Form Validati...
    🔗 Node JS Full Course (with source code) for building the backend REST API that will receive your form submissions: • Node.js Full Course fo...
    🔗 FontAwesome for React:
    fontawesome.com/v5.15/how-to-...
    🔗 RegExr for Regular Expressions: regexr.com/
    📚 Accessible Form References:
    WebAIM.org - Advanced Forms: webaim.org/techniques/forms/a...
    WebAIM.org - Form Validation: webaim.org/techniques/formval...
    MDN - Aria Attributes:
    aria-invalid: developer.mozilla.org/en-US/d...
    aria-describedby: developer.mozilla.org/en-US/d...
    aria-live: developer.mozilla.org/en-US/d...
    aria-label: developer.mozilla.org/en-US/d...
    🔗 ES7 React JS Snippets Extension for VS Code:
    marketplace.visualstudio.com/...
    🔗 React Dev Tools Extension for Chrome:
    chrome.google.com/webstore/de...
    📚 References:
    ReactJS Official site: reactjs.org/
    React Wikipedia: en.wikipedia.org/wiki/React_(...)
    React Jobs: www.ziprecruiter.com/candidat...
    ✅ Follow Me:
    Github: github.com/gitdagray
    Twitter: / yesdavidgray
    LinkedIn: / davidagray
    Blog: yesdavidgray.com
    Reddit: / daveoneleven
    Was this tutorial about creating a React User Login form with authentication, axios, and accessibility features helpful? If so, please share. Let me know your thoughts in the comments.
    #react #login #form

ความคิดเห็น • 404

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  2 ปีที่แล้ว +36

    Creating a login with authentication is often a required part of creating a web app. In this tutorial, you will learn how to create a login form that submits information with Axios for authentication with a server. The login will also be created with accessibility in mind. This is really part 2 of a registration / login tutorial series. Part 1 is the registration with validation tutorial found here: th-cam.com/video/brcHK3P6ChQ/w-d-xo.html

    • @SmartWizzard
      @SmartWizzard 2 ปีที่แล้ว

      Hi @dave, I missed the other video which I will watch later but I have future request for this video.
      Can you add a session & localStorage to maintain the use session for certain period so that when you refresh local host it won't log you out until and unless you logout or session expires.
      These are a good add-ons to this project.
      Cheers! and thanks for your work.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +4

      Hey SW, thanks for the request! I do not recommend localStorage (or sessionStorage) for storing tokens even though the majority of tutorials use them. A refresh token should really be in an http-Only secure cookie with the access token stored in app state. I cover this in detail for the backend in my Node JS full course: th-cam.com/video/f2EqECiTBL8/w-d-xo.html But you are absolutely right about adding a persistent login to this series, and I plan to do that (with the cookie)! 💯🚀

    • @pranjalruhela1103
      @pranjalruhela1103 2 หลายเดือนก่อน

      Hi @DaveGrayTeachesCode I wanted to know which sections in the node video (its 7 hours long) correspond to this project? can you give us the chapters exactly

  • @tabliqatchi6696
    @tabliqatchi6696 2 ปีที่แล้ว +13

    How amazing, this is the first tutorial I've watched from you and it's so very well organized and you explain things bit by bit. Thanks a lot Dave.

  • @r0ck3th76
    @r0ck3th76 2 ปีที่แล้ว +37

    Finally someone that speaks clear and concise. Loved the tutorial going to look at your full course. Thanks alot.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      You're welcome! 🙏

    • @darkNovaskar
      @darkNovaskar 11 หลายเดือนก่อน

      I know what you're talking about. Those thick azz peanut butter on the roof of their mouth type accents. They're very annoying when looking for solutions in coding when coding is already hard enough 😤.......

  • @shawn.builds
    @shawn.builds 2 ปีที่แล้ว +24

    Dave, your channel is massively underrated. Really well put together + love how each video in the series builds on the previous. This is exactly what I look for in Udemy courses that I pay for! Liked and subbed!!

  • @DH-jw4th
    @DH-jw4th 2 ปีที่แล้ว +2

    Thank you for responding with this video after my comment on the react tutorial. Your course stacks backend and front end expertly! Now, the server will have issued a refresh token in the form of a HTTP cookie. I cant wait to see how you handle the refresh in the client app!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you, DH! I'm also looking forward to setting up role-based protected routes!

  • @santiagopetrungaro
    @santiagopetrungaro 2 ปีที่แล้ว +7

    This series of videos is exactly what I was looking for. Let me thank you for this great content! Perfectly explained and such a clean code that makes it even easier for someone to understand what is being explained. Thanks again

  • @ivana1755
    @ivana1755 ปีที่แล้ว +3

    Couldn’t be more clear! I’ve already have worked doing some things in React but this wrap up my knowledge rather nicely! Congrats 🎉 I just subscribed!

  • @vincent3542
    @vincent3542 2 ปีที่แล้ว +2

    dave is the only youtuber, who before i even watched the video, i gave a thumbs up.
    quality of content, delivery of concepts all neatly wrapped and can be understood in depth 😍😘

  • @nirajchandrajoshi
    @nirajchandrajoshi 17 วันที่ผ่านมา

    You have done a great job; I am watching this in 2024 and I will not hesitate to say that I didn't find such tutorial on entire you tube. So super helpful to me.

  • @saadarman4718
    @saadarman4718 7 หลายเดือนก่อน +1

    Great work, you have put so much effort in these tutorials. Learned a lot. Thanks.

  • @DanielGarcia-vc7ci
    @DanielGarcia-vc7ci ปีที่แล้ว

    just landed here today and I want to say that this channel is amazing!

  • @user-mv9jn7vd2u
    @user-mv9jn7vd2u 11 หลายเดือนก่อน

    I am still a beginner web developement but I really apreciate your work. Thank you

  • @danielguise
    @danielguise 6 หลายเดือนก่อน

    Brilliant! This is amazing content. You have an incredible ability to get the complexity across, thank you so much.

  • @harmez7
    @harmez7 ปีที่แล้ว

    OMG, you're so good at making things complicated for beginners !

  • @Serhii_lolovich
    @Serhii_lolovich 2 ปีที่แล้ว +1

    amazing man

  • @Dame-Techie
    @Dame-Techie ปีที่แล้ว +2

    Very Easy to follow tutorial. Loved every bit of it. Will definitely watch the entire playlist and more of your courses.

  • @hamidabdolrahimi4606
    @hamidabdolrahimi4606 ปีที่แล้ว

    Thank you man. Awesome, best tutorial ever. Keep it up

  • @sabrinalucianavieirapinto5602
    @sabrinalucianavieirapinto5602 2 ปีที่แล้ว +1

    Amazing tutorial, I learn much things that I was struck in, thank you!

  • @ryant2350
    @ryant2350 2 ปีที่แล้ว +1

    Amazing tutorials Dave, truly.

  • @iliasswork6623
    @iliasswork6623 ปีที่แล้ว +1

    Dave, I can't thank you enough for this amazing content. Thank You!

  • @aaaliii4u
    @aaaliii4u ปีที่แล้ว +1

    you're the coder Dave.. thanks for such awesome stuff!

  • @tarrasuribabu9571
    @tarrasuribabu9571 ปีที่แล้ว +6

    Thank so much. In India we call teacher as GURU. Your my guru from now on.

  • @rafaelceballos8433
    @rafaelceballos8433 2 ปีที่แล้ว +1

    I like how specific this is. Thank you for making content for us beginners and intermidiate users.

  • @companyjoe
    @companyjoe 2 ปีที่แล้ว

    The clarity, the excellent presentation. Best in TH-cam. I'll be referring to you as Boss.

  • @learner8084
    @learner8084 10 หลายเดือนก่อน

    This guy is great. I like the tutorial a lot and learnt a lot too !

  • @rishavmasih9450
    @rishavmasih9450 5 หลายเดือนก่อน

    Damn, one of the best youtube channels in the developer space.

  • @preethpalsinghthakur7748
    @preethpalsinghthakur7748 2 ปีที่แล้ว

    Excellent tutorial.Thanks alot Dave.

  • @gandamraviteja7019
    @gandamraviteja7019 11 หลายเดือนก่อน

    Well explained hats off to u Dave U r helping me a lot thanks is a very tiny word for ur work amazing buddy

  • @aleksandrpetrov3938
    @aleksandrpetrov3938 11 หลายเดือนก่อน

    Hi, Dave. Ty for your lessons. Why do you put post request body in JSON.stringify function? We can just put js object there as the 2nd parameter { user, pwd }

  • @DevBigEazi
    @DevBigEazi ปีที่แล้ว +1

    This is the most straight forward tutorial i have ever come accrossed. Thanks to you Dave

  • @abraham.tesfay
    @abraham.tesfay 2 หลายเดือนก่อน

    Great tutorials. Thank you.

  • @GabrielMartinez-ez9ue
    @GabrielMartinez-ez9ue 2 ปีที่แล้ว

    Excellent material as always.

  • @prasathj7436
    @prasathj7436 11 หลายเดือนก่อน

    Excellent tutorial. Thanks a lot.

  • @user-sx5og3ly8b
    @user-sx5og3ly8b 2 ปีที่แล้ว +1

    Great job. Thanks Dave.

  • @ismailhrana3915
    @ismailhrana3915 2 ปีที่แล้ว

    Thanks for describing every steps in details and thanks again for maintaining code quality.
    #subscribed

  • @kaushikchopra3149
    @kaushikchopra3149 9 หลายเดือนก่อน +1

    After so many days of searching on TH-cam, I stumbled upon your video playlist on how to set refreshTokens and use them in a React app. I also learned a lot about Private Routes and other concepts. I'm extremely grateful for the valuable content you've provided. I really appreciate what you're doing. Although the playlist is a year old, it's still the best.
    Just one small doubt i have. In the context API, you have initialized the auth state and createContext with an empty object. If i do the same, it is not redirecting to the login page. May I know why?

  • @alexkost70
    @alexkost70 ปีที่แล้ว

    Great video, it helped me a lot!

  • @fmaciel2
    @fmaciel2 ปีที่แล้ว

    Thank you very much for the great tutorial! That's exactly what I've looking for to understand authentication.

  • @OleksandrProkopenko_ua
    @OleksandrProkopenko_ua ปีที่แล้ว

    Thanks very much. Awesome video!

  • @satellitesage2487
    @satellitesage2487 2 ปีที่แล้ว +1

    19:33 What else do you typically put inside of the api folder? Aside from the function that creates the axios instance. I already placed my api calls in their respective stores so.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      Good question - it really depends on how you (or your team) wants to organize the project. I like the modern Redux approach where you have a separate API layer with RTK Query and all endpoints are defined there.

  • @MrVipulLal
    @MrVipulLal 2 ปีที่แล้ว

    Great stuff, mate. Many thanks

  • @azaiezsene3165
    @azaiezsene3165 ปีที่แล้ว

    Thank you very much for this. It helped alot .
    I really think this tutorial is underrated.

  • @mayowaoladimeji1939
    @mayowaoladimeji1939 11 หลายเดือนก่อน

    I love your video !

  • @vnm_8945
    @vnm_8945 2 ปีที่แล้ว

    exactly what I need it, thank you very much!

  • @SniperKillerARG
    @SniperKillerARG 2 ปีที่แล้ว +1

    Thanks for sharing your knowledge!

  • @ravindusamaranayake3278
    @ravindusamaranayake3278 2 ปีที่แล้ว

    Great Job.Thanks, a lot Dave.

  • @nataliapylko6494
    @nataliapylko6494 ปีที่แล้ว

    Great explanation! Thank You for your work!

  • @atharvameher5880
    @atharvameher5880 6 หลายเดือนก่อน

    Thanks for source code man appreciate it. You gained new sub

  • @enzozarza1664
    @enzozarza1664 2 ปีที่แล้ว

    Great video, thank you 🙌

  • @pranjalruhela1103
    @pranjalruhela1103 2 หลายเดือนก่อน

    Hi Dave! Which parts of the Node JS video corresponds to the login project?

  • @tinvo5369
    @tinvo5369 2 ปีที่แล้ว

    this is the best tutorial for me, thanks!

  • @MrQVeeBoo
    @MrQVeeBoo ปีที่แล้ว

    super and very good explanation with example. very nice. thx

  • @davidencinas86
    @davidencinas86 ปีที่แล้ว

    Awesome. Thank you

  • @muhammedcansoy6131
    @muhammedcansoy6131 8 หลายเดือนก่อน

    excellent thank you !

  • @khaidoan5858
    @khaidoan5858 6 หลายเดือนก่อน

    at 24:58, is it necessary and safe to setAuth with pwd ? Thank you

  • @arpitsinha3835
    @arpitsinha3835 7 หลายเดือนก่อน

    what is the use of setAuth and auth variable ,code can be in flow to reach successful sign in without it

  • @QuotableWisdom783
    @QuotableWisdom783 ปีที่แล้ว +3

    Thanks Dave Gray I really appreciate your commitment and time to go through thing like these, and how you take your time to explain bit by bit of the code thanks👍👊

  • @kinzaamin3427
    @kinzaamin3427 ปีที่แล้ว

    found it very insightful.

  • @techtipsbydigitron9738
    @techtipsbydigitron9738 2 ปีที่แล้ว

    You are a good teacher. Everything that you explained realy understandable. Thank you very much..❤️🔥

  • @hippoguti2414
    @hippoguti2414 ปีที่แล้ว

    what a video! thank so much

  • @SenorMeoSanchez
    @SenorMeoSanchez 2 ปีที่แล้ว +4

    Hello Dave, thank you so much for such quality content you are creating! I have already completed the Node (loved the allowedOrigin) series and just done as well this one, with persisting login. Absolute illuminating !
    There is something I can't wrap my head on and if I remember correctly is in this video you first implemented.
    When creating the Login component, into the submit function, you call setAuth and pass to it user, psw, role and accessToken.
    Is it correct that all this values are gonna be stored into the app state globally (as long as the Provider pass it down) ? Is it necessary to pass it also the password?
    Thank you again for all the time you are investing !

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      I can't remember in which tutorial I break out the auth state to the Context API with an AuthProvider and create a useAuth hook, but that is eventually what happens. Then whatever component needs the auth state can just bring in the useAuth hook. Early on in this series, I may have just put the auth state in the login component until the expanded access was needed.

  • @jamesxiao4996
    @jamesxiao4996 2 ปีที่แล้ว +1

    Hi Dave,
    First of all thanks for these great tutorials!!
    What's the difference between this tutorial and your "React Login Authentication with JWT Access, Refresh Tokens, Cookies and Axios" tutorial.
    Also, is the backend that you use in this tutorial created in the full Node js Guide? Thanks!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      You're welcome! This is part of a video series. This video is the 2nd video. The other one you mention is the 3rd video. Playlist: th-cam.com/play/PL0Zuz27SZ-6PRCpm9clX0WiBEMB70FWwd.html ...yes, the backend is created in my Node.js full course here: th-cam.com/video/f2EqECiTBL8/w-d-xo.html

  • @danieltkach2330
    @danieltkach2330 2 ปีที่แล้ว +1

    Is it correct to set the axios base url depending on whether we are in a dev or prod environment? I've been doing the env checking using interceptors, and I discovered here the base url setting, which one is better in this case? Thanks for sharing your knowledge Dave.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      The env with a production vs development check is great. The environment variable still provides a constant for the BASE_URL which is the main idea.

  • @danieltkach2330
    @danieltkach2330 2 ปีที่แล้ว

    Another question, what's the reason you use JSON.stringify to parse the body you send in a post request? I've always sent the object directly. What are the pros and cons?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Good question! 💯 This is something I did not need to do with Axios, but you must do it if you just use the fetch API. There is no con, but if you do not do it, Axios will do the object to JSON conversion automatically. Another reason to like Axios!

  • @dilrukshiperera-yo5br
    @dilrukshiperera-yo5br 14 วันที่ผ่านมา

    This video helped me.

  • @kostyapolishko6282
    @kostyapolishko6282 2 ปีที่แล้ว

    Thank you so much. It is a good example, but how to call axiosPrivate not inside the Component, for example inside redux operations?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      You're welcome! 🙏I've had several requests for a login flow with Redux which will make a good future tutorial! 💯

  • @alexmephors
    @alexmephors ปีที่แล้ว

    I have never seen a tutorial this perfect and amazing. Thanks so much!!

  • @Babajagrarox
    @Babajagrarox 6 หลายเดือนก่อน

    Dave when I hit refresh in my browser after log in it kicks me back to login :(

  • @bacwithjasmin3001
    @bacwithjasmin3001 6 หลายเดือนก่อน

    I did all the code but I don't find the user in my bdd and I can add the same user with same proprieties and it makes n error what to do ?

  • @emAyush56
    @emAyush56 ปีที่แล้ว

    Hey Dave, your tutorials have been really helpful to me. I have this question @ 22:37 - What is the thing with withCredentials? Why do we need to specify it? I was working with an API and I was getting an error when I set withCredentials to true. I have googled about it a bit but it wasn't clear to me why it is needed? Could help me understand its need?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Glad to hear that. It is a config setting in axios. If I remember correctly, I used axios here. Reference this page: axios-http.com/docs/req_config

  • @brucelee7782
    @brucelee7782 3 หลายเดือนก่อน

    Isnt a generic error message better than a specific one like "no server response"? For mitigating hackers

  • @kirillzlobin7135
    @kirillzlobin7135 11 หลายเดือนก่อน

    25:00 But why should we save the password in AuthContext. Is it considered to be safe?

  • @farzindev
    @farzindev 2 ปีที่แล้ว +1

    As always, you make it so simple for us. thank you.
    my question is, what happens if I add react-query to my app. should I change this AuthProvider and use react-query somehow? can you make a video about that? Thank you

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      Thank you, Francis! 🙏 Yes, it would be a good refactor with React Query, and I plan to do this video soon! 💯

  • @akashagrawal5067
    @akashagrawal5067 หลายเดือนก่อน

    Hi, pls let me know which nodeJS tutorial need to follow of your youtube channel so that I can also create the same backend environment in my local with authentication fucntionality which you are using in this ReactJS tutorial.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  หลายเดือนก่อน

      The Node.js Full Course - there should be a link to it in this video's description.

  • @keniamartinez5351
    @keniamartinez5351 2 ปีที่แล้ว

    You are the best , thank you!

  • @vishwasmakwana125
    @vishwasmakwana125 ปีที่แล้ว +1

    Hi Dave ,
    Your tutorial is awesome , I want to follow along react-authentication series but i dont want to create nodejs project for backend from scratch that we are using in current project.
    Is there any way i can directly setup backend and focus on react part . If there is way please let me know it will be greate help
    Thanks

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      You may find another Rest API, but it may not respond the same. You could possibly learn the React concepts without using the backend, but if you want it to function as you go, you'll need the backend Rest API.

  • @Adrian-nc1tp
    @Adrian-nc1tp ปีที่แล้ว +1

    I am currently trying to make a sign in and sign up with vite react js and also using Axios as the database. What is the difference between the normal react js and the vite react js? Is there a way for me to convert between react js to vite react js?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      It is still just React.js. Vite is more for the dev environment and build. Just check the Vite.js site for the changes on things like environment variables, static assets, etc: vitejs.dev/guide/

  • @charliema3762
    @charliema3762 2 ปีที่แล้ว +2

    I've watched a few of your videos. You are a really fine instructor, and your pacing is perfect. Thank you!

  • @thomass2040
    @thomass2040 2 ปีที่แล้ว

    Amazing content!!! !! :)
    Added to my TOP content providers 💪💪
    one thing, it would be nice to have this backend api link to test it out on ourself or maybe some json-server to mock it somehow :)
    Keep doing, amazing work! waiting for same with typescirpt 😊😊

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you, Thomas! You can use the Node.js backend that is built in my Node.js for Beginners course here: th-cam.com/video/f2EqECiTBL8/w-d-xo.html

  • @zeruiwang276
    @zeruiwang276 2 ปีที่แล้ว

    Thank you so much Dave ! You are really amazing, that's so much learned in a so concise and clear way.

  • @odigwenwike7575
    @odigwenwike7575 3 หลายเดือนก่อน

    Any reason why you're saving user password in global context?

  • @ImperiousRex13
    @ImperiousRex13 2 ปีที่แล้ว

    Thanks, Dave really great tutorial. My only issue now is figuring out how to logout

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      If you keep going in this React Login series, a logout is added to the flow.

  • @anushangapavith7162
    @anushangapavith7162 2 ปีที่แล้ว

    Thank you for the video it was very helpful ❤️
    But I have a concern about logout. It seems you haven't implement a logout function here... 🤔

  • @mayurdevhare7289
    @mayurdevhare7289 ปีที่แล้ว

    Hello Dave, Your Tutorial is awesome can you please tell us how you connect with database mysql and curd operations

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      Thank you! Connecting to MySQL or any other database happens in the backend code. If you use Node.js with MySQL, you could use something like Sequelize to connect with the database: www.npmjs.com/package/sequelize

  • @user-hk2zq3lt1m
    @user-hk2zq3lt1m 2 ปีที่แล้ว

    Hello dave i have followed your video and successfully connected back and front ends, thank you for that. But i have a question:
    Right now im getting my data to the body so it comes with param, what do i have to change in login.js to make it send with data

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +1

      You can keep going in this React Login series to see how I send data and interact with a Node.js REST API. With a login form, you should send a POST request to login. As you mentioned, your data should be in the body of the request.

  • @tarekghosn3648
    @tarekghosn3648 ปีที่แล้ว

    hmmm will you be my next binge?

  • @adamwarzecha4439
    @adamwarzecha4439 ปีที่แล้ว +1

    What will happend if user refreshes page after logging in? Won't context data be lost ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      Link to Login Persistence video in the description, but I suggest watching the full series in order.

  • @De_Bryan
    @De_Bryan 2 ปีที่แล้ว

    Thanks for the tutorial. I have been getting ..Cannot read properties of undefined (reading 'focus')..when invoking errRef.current.focus(); Have the same issues with focus in registration. Could it have something to do with the react version? Your response will be appreciated.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      React is Javascript underneath so focus and the version are not the issue. It sounds like you are calling focus on something React says is undefined. You can download my source code and compare to see what is different in your code.

    • @tenlongfingers70
      @tenlongfingers70 ปีที่แล้ว

      For anyone else like me having this same problem and looking in the comments for the answer: it's undefined until you finish the input attributes for the username. That's where we finally define the focus. In other words, this error goes away a few more minutes into the tutorial, lol.

  • @ozanveyselcomez9466
    @ozanveyselcomez9466 ปีที่แล้ว

    Hello Dave, it was so useful source for people who like me at the begging of the react. But I'm confused about access token. We didn't use bearer token, so that for other pages, I can't send my access token to server. For example, I tried to create user list, but while I am using 'get' method I don't know how to add my access token to header. Can you help?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว

      If you keep going in this series (other videos linked in description), you will learn how to send data to the server, too. The token will go in the authorization header with the word Bearer followed by a space and then the token.

  • @daniilpogolovkin8221
    @daniilpogolovkin8221 10 หลายเดือนก่อน

    Thanks!

  • @kirillzlobin7135
    @kirillzlobin7135 11 หลายเดือนก่อน

    28:15 Nice trick. Did not know about that :)

  • @user-vs7lj4zy5d
    @user-vs7lj4zy5d 2 ปีที่แล้ว

    If I have a big app, and I'm rendering a lot of things in app.js, how and where do I put in app a login form page, so I could see an app after authorisation in login form? thx a lot in advance, your videos are amazing

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you! Go to the next video in this React login series. It handles routing with protected routes in React Router v6.

  • @tetyanagon3342
    @tetyanagon3342 9 หลายเดือนก่อน

    TY!

  • @rogerfantw
    @rogerfantw 2 ปีที่แล้ว +1

    Thanks for your amazing and concise tutorial.
    Would you make a tutorial for Django Rest Framework, since I wanna use Django as a backend Server instead of Node JS.

  • @diebeziehung1278
    @diebeziehung1278 8 หลายเดือนก่อน

    First i want to give you Dave so many thanks for your videos, its a greatful job what you do. And hello together in the community.
    I have tried to insert 1:1 code in my project, for die Role-Based Authorization.
    I am very beginner for react. I get to the home route after a login, so far so good. But after I want to call the home route again, the user is no longer authenticated. Unfortunately, I can't understand what the problem might be, so I'm contacting you here to perhaps get a tip. In this case, is it a safe method to save the AuthState in the LocalStorage?
    Otherwise, sorry for my English and hope that you get on well with React ;) (FYI: UI-Style with ChakraUI)

  • @robertd.hewson8451
    @robertd.hewson8451 11 หลายเดือนก่อน

    thx dave

  • @yassinbagane
    @yassinbagane ปีที่แล้ว

    the problem when you store token with useContext and refresh u lose state how can i handle that ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  ปีที่แล้ว +1

      You always lose app state when you refresh an app. In two more videos in this series the topic is persistent login. That will show you how.

  • @igorrenan2063
    @igorrenan2063 2 ปีที่แล้ว

    Hi! I'm using typescript with react and it's giving an error in the "ref" property of the input. How can I solve? can you help me?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว +2

      Google to the rescue! I searched for: useRef + Typescript ..and the first result: linguinecode.com/post/how-to-use-react-useref-with-typescript 🚀

  • @8294685725
    @8294685725 ปีที่แล้ว

    Thank you very much.

  • @AliHamza-eu2fx
    @AliHamza-eu2fx 2 ปีที่แล้ว

    Thanku sir this tutorial is helpfull.please make a Angular Mean series thanku...!!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 ปีที่แล้ว

      Thank you! 🙏 And thanks for the request, too! 🚀