Skip to content

getBasket(basketId: string): Promise<Basket | null>

The getBasket method allows to retrieve the contents of a basket with a given id.

Input parameters

basketId

basketId is a mandatory parameter of the string type that represents the id of the basket we want to get.

Returned value

A returned value has a type of Promise<Basket | null>. If a basket exists then it returns a Basket model. If it doesn't then it returns null.

Example

In this example we make a basketUpdaterApi call to retrieve the contents of a basket with a given id.

useStorefront(async (storefront) => {
    const basketUpdaterApi = storefront.getApiSync('basketUpdaterApi');

    const basket = basketUpdaterApi.getBasket(12);

    console.log('shipping address provided in a basket:', basket.shippingAddress);
});

Basket Updater API methods reference