AddressesResource
This class is used to send requests to Address API Routes part of the Store Customer API Routes. All its method
are available in the JS Client under the medusa.customers.addresses
property.
All methods in this class require customer authentication.
Methods
addAddress
Add an address to the logged-in customer's saved addresses.
Example
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.addresses.addAddress({
address: {
first_name: "Celia",
last_name: "Schumm",
address_1: "225 Bednar Curve",
city: "Danielville",
country_code: "US",
postal_code: "85137",
phone: "981-596-6748 x90188",
company: "Wyman LLC",
province: "Georgia",
}
})
.then(({ customer }) => {
console.log(customer.id);
})
Parameters
The address to add.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the customer's details, including the customer's addresses in the shipping_addresses
attribute.
ResponsePromise
ResponsePromise<StoreCustomersRes>Requiredshipping_addresses
attribute.deleteAddress
Delete an address of the logged-in customer.
Example
Parameters
address_id
stringRequiredThe ID of the address to delete.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the customer's details, including the customer's addresses in the shipping_addresses
attribute.
ResponsePromise
ResponsePromise<StoreCustomersRes>Requiredshipping_addresses
attribute.updateAddress
Update an address of the logged-in customer.
Example
Parameters
address_id
stringRequiredThe address's ID.
The attributes to update in the address.
customHeaders
Record<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
ResponsePromise
ResponsePromise<StoreCustomersRes>RequiredResolves to the customer's details, including the customer's addresses in the shipping_addresses
attribute.
ResponsePromise
ResponsePromise<StoreCustomersRes>Requiredshipping_addresses
attribute.Was this section helpful?