Using the FileSystem API

Now, within Order.js add the following two methods

    importCart: async () => {
        const [ handle ] = await window.showOpenFilePicker();
        const file = await handle.getFile();
        try {
            const content = JSON.parse(await file.text());
            console.log(content);
            if (content instanceof Array && content.length > 0) {
                Order.cart = content;
            } else {
                alert("File is invalid");
            }
            Order.render();
        } catch (e) {
            console.log(e);
            alert("File is invalid");
        }
    },
    exportCart: async () => {
        const handle = await window.showSaveFilePicker({
            types: [{
              description: "JSON Cart File",
              accept: {
                "application/json": [".json"],
              },
            }]
        });
        const file = await handle.getFile();
        const writable = await handle.createWritable();
        await writable.write(JSON.stringify(Order.cart));
        await writable.close();
    },