Use the query

This commit is contained in:
Luis Alvarez
2020-09-30 13:36:02 -05:00
parent 9ca977c44f
commit b9be9ea749
4 changed files with 26 additions and 12 deletions

View File

@@ -69,12 +69,3 @@ export default class BigcommerceAPI implements CommerceAPI {
};
}
}
let h = new BigcommerceAPI({ apiToken: '', commerceUrl: '' });
async function yay() {
const x = await h.getAllProducts<{ custom: 'val' }>({ query: 'yes' });
const y = await h.getAllProducts();
console.log(x.products);
}

9
lib/commerce-api.ts Normal file
View File

@@ -0,0 +1,9 @@
import BigcommerceAPI from './bigcommerce/api';
const API_URL = process.env.NEXT_EXAMPLE_BIGCOMMERCE_STOREFRONT_API_URL!;
const API_TOKEN = process.env.NEXT_EXAMPLE_BIGCOMMERCE_STOREFRONT_API_TOKEN!;
export const commerce = new BigcommerceAPI({
commerceUrl: API_URL,
apiToken: API_TOKEN,
});

View File

@@ -14,7 +14,7 @@ export interface CommerceAPI {
fetch<T>(query: string, queryData?: CommerceAPIFetchOptions): Promise<T>;
getAllProducts(options?: { query?: string }): Promise<any>;
getAllProducts(options?: { query: string }): Promise<any>;
}
// export default class CommerceAPI {