0

hi Basir

when I click the place order button , it does create the order in backend , i get the 201 message in “Network” header tab in the inspect. but the console shows following error

“PlaceOrderScreen.js:57 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘_id’) at HTMLButtonElement.eval (PlaceOrderScreen.js:57:58)”

below is the code for place order button

const PlaceOrderScreen = {
    after_render: async () => {
        document.getElementById(“placeorder-button”)
        .addEventListener(‘click’, async () => {
        const order = convertCartToOrder();
        showLoading();
        const data = await createOrder(order);

        hideLoading();
        if (data.error){
            showMessage(data.error);
        } else {
            cleanCart();
            document.location.hash =`/order/${data.order._id}`;

        }
        });
I get the error at code in bold. Any suggestion how to correct it. i have seen answer to similar question but could not get rid of this issue.
Thanks in advance.

Bassir Answered question March 10, 2023

hi
an update after several days and lot of changes finally manage to get the required results by clicking placeorder button. thanks