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•12mo ago
I don't see red squiggles, so VSCode clearly thinks it is. Are you getting any errors?
vencewho
vencewhoOP•12mo 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•12mo ago
it'll store some data in localstorage, yeah. It depends on how you use that data, and what data you're storing
vencewho
vencewhoOP•12mo ago
Will it be accessible to all of my react components?
Jochem
Jochem•12mo 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
vencewhoOP•12mo ago
Okay, thanks. That solves that my question.
Jochem
Jochem•12mo 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