@@ -26,9 +26,6 @@ const PRODUCT_MODULE_ENABLED =
26
26
// The API_BASE_URL is set in the .env file. It is the base URL of your Next.js app.
27
27
const API_BASE_URL = process . env . NEXT_PUBLIC_BASE_URL || "http://localhost:8000"
28
28
29
- // Set DEBUG to true to console.log where the data is coming from.
30
- const DEBUG = false
31
-
32
29
/**
33
30
* Fetches a product by handle, using the Medusa API or the Medusa Product Module, depending on the feature flag.
34
31
* @param handle (string) - The handle of the product to retrieve
@@ -38,7 +35,6 @@ export async function getProductByHandle(
38
35
handle : string
39
36
) : Promise < { products : PricedProduct [ ] } > {
40
37
if ( PRODUCT_MODULE_ENABLED ) {
41
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
42
38
const data = await fetch ( `${ API_BASE_URL } /api/products/${ handle } ` )
43
39
. then ( ( res ) => res . json ( ) )
44
40
. catch ( ( err ) => {
@@ -48,7 +44,6 @@ export async function getProductByHandle(
48
44
return data
49
45
}
50
46
51
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
52
47
const { products } = await medusaRequest ( "GET" , "/products" , {
53
48
query : {
54
49
handle,
@@ -84,7 +79,6 @@ export async function getProductsList({
84
79
const limit = queryParams . limit || 12
85
80
86
81
if ( PRODUCT_MODULE_ENABLED ) {
87
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
88
82
const params = new URLSearchParams ( queryParams as Record < string , string > )
89
83
90
84
const { products, count, nextPage } = await fetch (
@@ -102,7 +96,6 @@ export async function getProductsList({
102
96
}
103
97
}
104
98
105
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
106
99
const { products, count, nextPage } = await medusaRequest (
107
100
"GET" ,
108
101
"/products" ,
@@ -135,7 +128,6 @@ export async function getCollectionsList(
135
128
offset : number = 0
136
129
) : Promise < { collections : ProductCollection [ ] ; count : number } > {
137
130
if ( PRODUCT_MODULE_ENABLED ) {
138
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
139
131
const { collections, count } = await fetch (
140
132
`${ API_BASE_URL } /api/collections?offset=${ offset } ` ,
141
133
{
@@ -155,7 +147,6 @@ export async function getCollectionsList(
155
147
}
156
148
}
157
149
158
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
159
150
const { collections, count } = await medusaRequest ( "GET" , "/collections" , {
160
151
query : {
161
152
offset,
@@ -185,7 +176,6 @@ export async function getCollectionByHandle(handle: string): Promise<{
185
176
nextPage : number
186
177
} > {
187
178
if ( PRODUCT_MODULE_ENABLED ) {
188
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
189
179
const data = await fetch ( `${ API_BASE_URL } /api/collections/${ handle } ` )
190
180
. then ( ( res ) => res . json ( ) )
191
181
. catch ( ( err ) => {
@@ -195,7 +185,6 @@ export async function getCollectionByHandle(handle: string): Promise<{
195
185
return data
196
186
}
197
187
198
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
199
188
const data = await medusaRequest ( "GET" , "/collections" , {
200
189
query : {
201
190
handle : [ handle ] ,
@@ -232,7 +221,6 @@ export async function getProductsByCollectionHandle({
232
221
nextPage : number
233
222
} > {
234
223
if ( PRODUCT_MODULE_ENABLED ) {
235
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
236
224
const { response, nextPage } = await fetch (
237
225
`${ API_BASE_URL } /api/collections/${ handle } ?currency_code=${ currencyCode } &page=${ pageParam . toString ( ) } `
238
226
)
@@ -247,7 +235,6 @@ export async function getProductsByCollectionHandle({
247
235
}
248
236
}
249
237
250
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
251
238
const { id } = await getCollectionByHandle ( handle ) . then (
252
239
( res ) => res . collections [ 0 ]
253
240
)
@@ -283,7 +270,6 @@ export async function getCategoriesList(
283
270
count : number
284
271
} > {
285
272
if ( PRODUCT_MODULE_ENABLED ) {
286
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
287
273
const { product_categories, count } = await fetch (
288
274
`${ API_BASE_URL } /api/categories?offset=${ offset } &limit=${ limit } ` ,
289
275
{
@@ -303,7 +289,6 @@ export async function getCategoriesList(
303
289
}
304
290
}
305
291
306
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
307
292
const { product_categories, count } = await medusaRequest (
308
293
"GET" ,
309
294
"/product-categories" ,
@@ -336,7 +321,6 @@ export async function getCategoryByHandle(categoryHandle: string[]): Promise<{
336
321
product_categories : ProductCategoryWithChildren [ ]
337
322
} > {
338
323
if ( PRODUCT_MODULE_ENABLED ) {
339
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
340
324
const data = await fetch (
341
325
`${ API_BASE_URL } /api/categories/${ categoryHandle } ` ,
342
326
{
@@ -353,8 +337,6 @@ export async function getCategoryByHandle(categoryHandle: string[]): Promise<{
353
337
return data
354
338
}
355
339
356
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
357
-
358
340
const handles = categoryHandle . map ( ( handle : string , index : number ) =>
359
341
categoryHandle . slice ( 0 , index + 1 ) . join ( "/" )
360
342
)
@@ -403,7 +385,6 @@ export async function getProductsByCategoryHandle({
403
385
nextPage : number
404
386
} > {
405
387
if ( PRODUCT_MODULE_ENABLED ) {
406
- DEBUG && console . log ( "PRODUCT_MODULE_ENABLED" )
407
388
const { response, nextPage } = await fetch (
408
389
`${ API_BASE_URL } /api/categories/${ handle } ?currency_code=${ currencyCode } &page=${ pageParam . toString ( ) } ` ,
409
390
{
@@ -423,7 +404,6 @@ export async function getProductsByCategoryHandle({
423
404
}
424
405
}
425
406
426
- DEBUG && console . log ( "PRODUCT_MODULE_DISABLED" )
427
407
const { id } = await getCategoryByHandle ( [ handle ] ) . then (
428
408
( res ) => res . product_categories [ 0 ]
429
409
)
0 commit comments