filmov
tv
I'm getting an error 'ReferenceError: localStorage is not defined' in my angular project

Показать описание
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!I'm getting an error "ReferenceError: localStorage is not defined" in my angular project
In my Angular project, I want to using a localStorage.
But I get a error.
Here is my code.
if (siteId) {
}
if (siteId) {
}
Here is the error.
ERROR ReferenceError: localStorage is not defined
at callHookInternal (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5640:10)
at callHook (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5655:7)
at callHooks (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5629:9)
at executeInitAndCheckHooks (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5598:5)
at refreshView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10505:11)
at detectChangesInView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10657:5)
at detectChangesInViewIfAttached (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10640:3)
at detectChangesInEmbeddedViews (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10616:7)
at refreshView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10517:5)
ERROR ReferenceError: localStorage is not defined
at callHookInternal (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5640:10)
at callHook (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5655:7)
at callHooks (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5629:9)
at executeInitAndCheckHooks (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:5598:5)
at refreshView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10505:11)
at detectChangesInView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10657:5)
at detectChangesInViewIfAttached (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10640:3)
at detectChangesInEmbeddedViews (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10616:7)
at refreshView (F:\companies\IOT-Billing\source\OnLineSignUp\.angular\cache\18.2.3\vite\deps_ssr\chunk-DH64UGMO.js:10517:5)
I want to store and get token in localStorage.
Tags: aSource of the question:
Question and source license information: