-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from Baroshem/chore/1.0.0-rc.1
Chore/1.0.0 rc.1
- Loading branch information
Showing
21 changed files
with
3,479 additions
and
2,439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,9 @@ | |
|
||
--- | ||
|
||
This composable uses [@medusa/medusa-js](https://www.npmjs.com/package/@medusajs/medusa-js) under the hood and gives you access to the Medusa client. | ||
This composable uses [@medusajs/js-sdk](https://www.npmjs.com/package/@medusajs/js-sdk) under the hood and gives you access to the Medusa client. | ||
|
||
Check the official documentation of Medusa JS Client to learn more about all the available options [here](https://docs.medusajs.com/js-client/overview/) | ||
Check the official documentation of Medusa JS Client to learn more about all the available options [here](https://docs.medusajs.com/resources/js-sdk) | ||
|
||
## Fetching Products | ||
|
||
|
@@ -13,7 +13,7 @@ Here is an example of a fetch using the `list` method: | |
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
const { products } = await client.products.list(); | ||
const { products } = await client.store.product.list(); | ||
</script> | ||
``` | ||
|
||
|
@@ -24,31 +24,31 @@ Here is an example of a fetch using the `list` method: | |
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
const { collections } = await client.collections.list(); | ||
const { collections } = await client.store.collection.list(); | ||
</script> | ||
``` | ||
|
||
## Authenticating | ||
|
||
Authenticating users with `authenticate` method: | ||
Authenticating users with `login` method: | ||
|
||
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
await client.auth.authenticate({ email: '[email protected]', password: 'test1234' }); | ||
await client.auth.login('customer', 'emailpass', { email: '[email protected]', password: 'test1234' }); | ||
</script> | ||
``` | ||
|
||
This will create a new cookie called `connect.sid` that will have a `httpOnly` flag set to true (which means that it is not accessible from the frontend JS code). | ||
This will create a new cookie (if the authentication type is set to session) called `connect.sid` that will have a `httpOnly` flag set to true (which means that it is not accessible from the frontend JS code). | ||
|
||
You can now fetch data about the currently logged in user as shown below: | ||
|
||
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
const { customer } = await client.auth.getSession() | ||
const { customer } = await client.store.customer.retrieve() | ||
</script> | ||
``` | ||
|
||
|
@@ -66,12 +66,12 @@ To save the `cart_id` in `localStorage` you can use the following code: | |
const cartId = localStorage.getItem('cart_id') || null | ||
if (!cartId) { | ||
const { cart } = await client.carts.create(); | ||
const { cart } = await client.store.cart.create({ region_id: 'reg_123' }); | ||
localStorage.setItem('cart_id', cart.id) | ||
// save the NEW cart to the store or the state | ||
} else { | ||
const { cart } = await client.carts.retrieve(cartId) | ||
const { cart } = await client.store.cart.retrieve(cartId) | ||
// save the EXISTING cart to the store or the state | ||
} | ||
|
@@ -89,12 +89,12 @@ To save the `cart_id` in a `cookie` you can leverage the `useCookie` composable | |
const cartId = useCookie('cart_id', { maxAge: 60 * 60 * 24 * 365 }); | ||
if (!cartId.value) { | ||
const { cart } = await client.carts.create(); | ||
const { cart } = await client.store.cart.create({ region_id: 'reg_123' }); | ||
cartId.value = cart.id | ||
// save the NEW cart to the store or the state | ||
} else { | ||
const { cart } = await client.carts.retrieve(cartId.value); | ||
const { cart } = await client.store.cart.retrieve(cartId.value); | ||
// save the EXISTING cart to the store or the state | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.