Skip to content

getOrders(): Promise<UserOrder[]>

The getOrders method allows you to get the information about the orders of a currently authenticated user.

Returned value

A returned value has a type of Promise<UserOrder[]> where UserOrder represents the UserOrder model.

Example

In this example we make a UserApi call to get all confirmed orders of an authenticated user.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const userOrders = await userApi.getOrders();

        const confirmedOrders = userOrders.filter((order) => order.confirm);

        console.log('ids of the confirmed orders:', confirmedOrders.reduce((orderIds, currOrder) => `${orderIds} ${currOrder.id}`));
    });

User API methods reference

Models reference