Issue
I was trying to set UNIX
time in local storage by:
let dt: number = Date.now();
localStorage.setItem('logged', dt+864000000);
Returning with error: Argument of type ‘number’ is not assignable to parameter of type
‘string’
It’s giving the same error when i use getItem
to read the logged
data.
Any solution?
Solution
Just try this
let dt: number = Date.now();
localStorage.setItem('logged', ""+dt+864000000);
Hope this works for you
Answered By – Mustafa Lokhandwala
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0