In take
you’re using the millisecond, you need to use the seconds here.
In map
you’re subtracting 1 from the milliseconds then multiply by 1000 giving you microseconds, you need to supply the correct milliseconds here.
I would do it like this:
switchMap(_ => {
let counter = 15 * 60; // seconds
return timer(0, 1000).pipe(
take(counter + 1),
// subtract the seconds that have past and turn the result into milliseconds
map(t => (counter - t) * 1000),
tap({
complete: () => {
console.log("countdown complete");
// redirect to login page
window.location.href = "http://IPHERE:8080/logout";
}
})
);
})
CLICK HERE to find out more related problems solutions.