first way
`
constructor() {
BasketService.clearBasketOnLoad();
}
static clearBasketOnLoad() {
localStorage.removeItem('basket');
localStorage.removeItem('basket_id');
console.log("Basket cleared from local storage on page load");
}
`
second Option:
clearBasketOnLoad() { localStorage.removeItem('basket'); localStorage.removeItem('basket_id'); console.log("Basket cleared from local storage on page load"); } ....... const basketService = new BasketService(); .... basketService.clearBasketOnLoad();
added above code inside basketService.ts file, so each reload of the page local storage gets cleared
first way ` constructor() { BasketService.clearBasketOnLoad(); }
static clearBasketOnLoad() { localStorage.removeItem('basket'); localStorage.removeItem('basket_id'); console.log("Basket cleared from local storage on page load"); } `
second Option:
clearBasketOnLoad() { localStorage.removeItem('basket'); localStorage.removeItem('basket_id'); console.log("Basket cleared from local storage on page load"); } ....... const basketService = new BasketService(); .... basketService.clearBasketOnLoad();
added above code inside basketService.ts file, so each reload of the page local storage gets cleared