I'm getting this error in the console.
__WEBPACK_IMPORTED_MODULE_1_shopify_buy___default.a is not a constructor
import Client, {Config} from 'shopify-buy';
const config = new Config({
domain: 'something.myshopify.com',
accessToken: 'xxxxxxxxxxxxxxxxxxx',
appId : x
});
const client = new Client(config);
Seems to be yelling at "const client = new Client(config);".... But that's what they have in their documentation. Am I doing something wrong? If so, how can I fix it?
I haven't tested this but from their documentation you can do something like following.
import ShopifyBuy from 'shopify-buy'; const shopClient = ShopifyBuy.buildClient({ apiKey: 'xxxxxxxxxxxxxxxxxxxx1403c107adc7e', domain: 'xxxxxxxxxxxxxxxx.myshopify.com', appId: '6', }); export function fetchAllProducts() { return new Promise((resolve, reject) => { shopClient.fetchAllProducts() .then((data) => { console.log('shopClient.fetchAllProducts', data); resolve(data); }).catch((error) => { console.error(new Error('Fetching products error!')); reject(error); }); }); }
Hope this will help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.