mirror of
https://github.com/vercel/commerce.git
synced 2025-06-07 16:56:59 +00:00
Enabled get all products with sdk. but needs normalizing
Added vs code debug script
This commit is contained in:
parent
c5d92d46ad
commit
7510cb03a8
22
.vscode/launch.json
vendored
Normal file
22
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Next: Node",
|
||||
"runtimeExecutable": "${workspaceFolder}/node_modules/next/dist/bin/next",
|
||||
"env": {
|
||||
"NODE_OPTIONS": "--inspect"
|
||||
},
|
||||
"port": 9229,
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Next: Full",
|
||||
"configurations": ["Next: Node"]
|
||||
}
|
||||
]
|
||||
}
|
@ -2,8 +2,13 @@ import { Product } from '@commerce/types/product'
|
||||
import { GetAllProductsOperation } from '@commerce/types/product'
|
||||
import type { OperationContext } from '@commerce/api/operations'
|
||||
import type { ElasticpathConfig, Provider } from '../index'
|
||||
import { gateway as MoltinGateway } from '@moltin/sdk'
|
||||
import data from '../../data.json'
|
||||
|
||||
const Moltin = MoltinGateway({
|
||||
client_id: process.env.NEXT_PUBLIC_ELASTICPATH_CLIENTID
|
||||
})
|
||||
|
||||
export default function getAllProductsOperation({
|
||||
commerce,
|
||||
}: OperationContext<any>) {
|
||||
@ -17,6 +22,9 @@ export default function getAllProductsOperation({
|
||||
config?: Partial<ElasticpathConfig>
|
||||
preview?: boolean
|
||||
} = {}): Promise<{ products: Product[] | any[] }> {
|
||||
//elastic path get all products
|
||||
let products = await Moltin.Products.Limit(200).All();
|
||||
console.log("All products", products);
|
||||
return {
|
||||
products: data.products,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user