Skip to content

Commit

Permalink
✨ use constants for Rest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DuvCharles committed Sep 26, 2023
1 parent d2413ee commit f3efbab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ export const TAGS = {
};

export const SYLIUS_API_ENDPOINT = '/api/v2/shop';

export const REST_METHODS = {
GET: 'GET',
POST: 'POST',
PUT: 'PUT',
DELETE: 'DELETE'
};
4 changes: 2 additions & 2 deletions lib/sylius/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SYLIUS_API_ENDPOINT } from 'lib/constants';
import { REST_METHODS, SYLIUS_API_ENDPOINT } from 'lib/constants';

const DOMAIN = `${process.env.SYLIUS_STORE_DOMAIN}`;
const ENDPOINT = `${DOMAIN}${SYLIUS_API_ENDPOINT}`;
Expand Down Expand Up @@ -53,7 +53,7 @@ export const getCollectionProducts = () => [];

// Cart
export const createCart = async () => {
const cart = await syliusRequest('POST', '/orders', { localeCode: 'fr_FR' });
const cart = await syliusRequest(REST_METHODS.POST, '/orders', { localeCode: 'fr_FR' });
return cart;
};
export const getCart = (cartId: string) => {
Expand Down

0 comments on commit f3efbab

Please sign in to comment.