- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Menu
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
Store and Retrieve Region
In this document, you'll learn how to store a customer's region's ID and retrieve the selected region.
Store Selected Region ID#
When the customer selects their region, for example, from a dropdown, store that region's ID in the localStorage
.
For example:
Then, you retrieve it later using the localSorage.getItem
method later:
Retrieve Selected Region#
To retrieve the selected region, use the Retrieve Region API route:
1const regionId = localStorage.getItem("region_id")2 3fetch(`http://localhost:9000/store/regions/${regionId}`, {4 credentials: "include",5 headers: {6 "x-publishable-api-key": process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY || "temp",7 },8})9.then((res) => res.json())10.then(({ region }) => {11 // do something with region.12 console.log(region)13})
Was this page helpful?