Local Storage Usage In React Using Axios

Hello, guys. Currently learning backend. I would like to as if my given code snippet is syntactically correct for storing user data from the database to local storage in react js.
No description
7 Replies
Jochem
Jochem•11mo ago
I don't see red squiggles, so VSCode clearly thinks it is. Are you getting any errors?
vencewho
vencewho•11mo ago
So far I'm not getting errors, but do you think I code it the right way? Like, is that how it works?
Jochem
Jochem•11mo ago
it'll store some data in localstorage, yeah. It depends on how you use that data, and what data you're storing
vencewho
vencewho•11mo ago
Will it be accessible to all of my react components?
Jochem
Jochem•11mo ago
localstorage is a browser api, any code running in the browser will be able to access it it's probably not the prefered way to pass around state in React though, but then that's a) a frontend question, and b) not something I personally know about 🙂
vencewho
vencewho•11mo ago
Okay, thanks. That solves that my question.
Jochem
Jochem•11mo ago
this entire question would've been better in #front-end, just for future reference. You're getting data through axios, but that doesn't make this a backend issue
Want results from more Discord servers?
Add your server