mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-02 08:23:14 +00:00
Fix loading of broken basket
This commit is contained in:
parent
503f47fd71
commit
cf385e5875
2 changed files with 3 additions and 9 deletions
|
@ -4,14 +4,7 @@ import { type CartItem, type Item } from "./types";
|
|||
import { getItemByUUID, postVerifyCart } from "./test-api";
|
||||
|
||||
function getLocal(): Record<string, CartItem> {
|
||||
let localData: Record<string, CartItem> = {};
|
||||
|
||||
try {
|
||||
localData = JSON.parse(localStorage.getItem("basket"));
|
||||
} catch (error) {
|
||||
console.error("Could parse basket JSON:", error);
|
||||
return localData;
|
||||
}
|
||||
let localData: Record<string, CartItem> = JSON.parse(localStorage.getItem("basket")) || {};
|
||||
|
||||
postVerifyCart(localData)
|
||||
.then((data: Record<string, CartItem>) => {
|
||||
|
@ -19,6 +12,7 @@ function getLocal(): Record<string, CartItem> {
|
|||
})
|
||||
.catch((error) => {
|
||||
console.error("Could not load basket:", error);
|
||||
return <Record<string, CartItem>>{};
|
||||
});
|
||||
|
||||
return localData;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue