I'm trying to reload my page after a function has completed, using the method:
window.location = "/"
but I keep getting the typescript error saying I can't assign a string to type location, which is weird because isn't a location always a string?
This is what I tried:
window.location.assign("/");
and it worked, but I don't understand why does the previous solution not work?
CodePudding user response:
window.location
is an Object
which has the propertly href
which is a String
. You want window.location.href = "/"
.