safak / youtube

5.04k stars 5.47k forks source link

Admin Panel : Empty LocalStorage throw error on RequestMethod #69

Open Bachir-Seghir opened 2 years ago

Bachir-Seghir commented 2 years ago

in requestMethod, we get the value of the TOKEN from localStorage but when we clear localStorage or open in another browser such as Incognito window requestMethod throw an error Uncaught TypeError: Cannot read properties of null (reading 'user') at Module../src/requestMethod.js (requestMethod.js:4:1)

I think a condition must be added to affect an empty string to the TOKEN if the localStorage is Empty

syarifabdurrahman commented 2 years ago

@Bachir-Seghir it's because in the video we use getItem local storage on the (persist: root) for the TOKEN, I recommend that you should use another localStorage to save TOKEN for example localStorage.getItem("ACCESS_TOKEN"); and set the localStorage.setItem("ACCESS_TOKEN", token); that when login or else