Js-buy-sdk: [1.0beta] Config not being exported

Created on 3 Oct 2017  路  5Comments  路  Source: Shopify/js-buy-sdk

Apologies for all the issues I've been opening. Hopefully this one will be somewhat useful.

I _think_ I found a bug in the exports. In your README, you recommend initialising a store like this: import Client, {Config} from 'shopify-buy';. However, while this works fine for Client, it seems like Config is undefined. Upon taking a closer look at the code, it seems like only Client is being exported.

From what I've seen it seems like Config is just a wrapper function that maps deprecated keys to their current ones. Based on this, initialising the store like this still works:

import Client from 'shopify-buy'

const config = {
  domain: 'domain.myshopify.com',
  storefrontAccessToken: 'token-here'
}

const client = new Client(config)

However, as soon as you use apiKey or accessToken, the code fails. I don't know if Config is being phased out on purpose or if it's just missing, but either way I thought I'd let you know!

Most helpful comment

@coalescecreate This is how I'm doing it (without import/export).

const Client = require('shopify-buy')

const config = {
  domain: 'domain.myshopify.com',
  storefrontAccessToken: 'XXX'
}

const shopify = Client.buildClient(config)

module.exports = shopify

All 5 comments

You shouldn't use the config class directly. This was updated in the migration guide, but looks like we missed the readme.

Please use Client.buildClient. it wraps up the config class and still gives you useful errors, without requiring you to have to instantiate two separate classes.

Sorry this is not super clear as to the intended way to create a new instance of the Client in the beta version.
The migration guide recommends that you also import Config which is not possible as @danielpost has mentioned.

@coalescecreate This is how I'm doing it (without import/export).

const Client = require('shopify-buy')

const config = {
  domain: 'domain.myshopify.com',
  storefrontAccessToken: 'XXX'
}

const shopify = Client.buildClient(config)

module.exports = shopify

Yeah, sorry. I thought the docs had been updated. @danielpost has it right 馃憤

Had the same issue. Took me a while to realize the docs were outdated. Thanks! This method is more straightforward (now that I know about it).

Was this page helpful?
0 / 5 - 0 ratings