Home

Issue: 1930

Problems with fetch when running shopify-buy sdk in SSR environment

[issue link]

I have setup shopify-buy as a plugin in my project running with the ssr: false flag. Unfortunately i am still running into the problem that the server is complaining about missing fetch function.

After a bit of digging i can see that fetch is utilized from graphql-js-client in shopify-buy, but what i do not understand is that when i switch off ssr why is the plugin still missing fetch? When i turn nuxt into spa mode it is working smoothly.

nuxt.config.js

plugins: [
    {src: '~/plugins/shopify-buy', ssr: false},
],
build: {
    vendor: [
        'shopify-buy'
    ]
}

plugins/shopify-buy.js

import Client, {Config} from 'shopify-buy'

const shopifyConfig = new Config({
  domain: 'removed.com',
  storefrontAccessToken: 'hidden'
})

export const shopifyClient = new Client(shopifyConfig)
skaermbillede 2017-10-23 kl 08 43 52
This question is available on Nuxt.js community (#c1723)