Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import Client from 'shopify-buy';
import { Provider } from 'react-redux';
import store from './store';
import './styles/shopify.css';
// build shopify client
const client = Client.buildClient({
storefrontAccessToken: 'YOUR_SHOPIFY_STOREFRONT_ACCESS_TOKEN',
domain: 'YOUR_MYSHOPIFY_STORE_URL'
});
store.dispatch({type: 'CLIENT_CREATED', payload: client});
// buildClient() is synchronous, so we can call all these after!
client.product.fetchAll().then((res) => {
store.dispatch({type: 'PRODUCTS_FOUND', payload: res});
});
client.checkout.create().then((res) => {
store.dispatch({type: 'CHECKOUT_FOUND', payload: res});
});
client.shop.fetchInfo().then((res) => {
store.dispatch({type: 'SHOP_FOUND', payload: res});
});
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import Client from 'shopify-buy';
import '../../shared/app.css';
const client = Client.buildClient({
storefrontAccessToken: 'dd4d4dc146542ba7763305d71d1b3d38',
domain: 'graphql.myshopify.com'
});
ReactDOM.render(
,
document.getElementById('root')
);
import React from 'react'
import Client from 'shopify-buy'
const client = Client.buildClient({
storefrontAccessToken: process.env.SHOPIFY_ACCESS_TOKEN,
domain: `${process.env.SHOP_NAME}.myshopify.com`,
})
export const defaultStoreContext = {
client,
adding: true,
checkout: { lineItems: [] },
products: [],
shop: {},
filteredType: 'all',
filteredSort: 'featured',
addVariantToCart: () => { },
addVariantToCartAndBuyNow: () => { },
removeLineItem: () => { },
updateLineItem: () => { },
import fetch from 'node-fetch';
import Client from 'shopify-buy';
global.fetch = fetch;
const client = Client.buildClient({
storefrontAccessToken: '20ef0127c6c37cee73dd149879a379a8',
domain: 'faheemnusrat.com'
});
export default client;
import React, { useState, useEffect } from 'react'
import Client from 'shopify-buy'
import Context from '~/context/StoreContext'
const client = Client.buildClient({
storefrontAccessToken: process.env.SHOPIFY_ACCESS_TOKEN,
domain: `${process.env.SHOP_NAME}.myshopify.com`,
})
const ContextProvider = ({ children }) => {
let initialStoreState = {
client,
adding: false,
checkout: { lineItems: [] },
products: [],
shop: {},
}
const [store, updateStore] = useState(initialStoreState)
useEffect(() => {
import React from 'react';
import Client from 'shopify-buy';
const client = Client.buildClient({
domain: 'gatsby-swag.myshopify.com',
storefrontAccessToken: '9aa73c089d34741f36edbe4d7314373a'
});
export const defaultStoreContext = {
client,
isCartOpen: false,
checkout: { lineItems: [] },
products: [],
shop: {},
addVariantToCart: () => {},
removeLineItem: () => {},
updateLineItem: () => {},
toggleCart: () => {}
};
import React from 'react'
import PropTypes from 'prop-types'
import Helmet from 'react-helmet'
import Client from 'shopify-buy'
import Header from '../components/header'
import './index.css'
const shopifyClient = Client.buildClient({
domain: `${process.env.GATSBY_SHOPIFY_SHOP_NAME}.myshopify.com`,
storefrontAccessToken: process.env.GATSBY_SHOPIFY_ACCESS_TOKEN,
})
const Layout = ({ children, data, ...props }) => (
<div>
<header>
</header></div>
import React from 'react'
import Client from 'shopify-buy'
const client = Client.buildClient({
domain: `${process.env.SHOPIFY_STORE_NAME}.myshopify.com`,
storefrontAccessToken: process.env.SHOPIFY_SECRET,
})
export const defaultStoreContext = {
client,
adding: false,
checkout: { lineItems: [] },
products: [],
shop: {},
filteredType: 'all',
addVariantToCart: () => {},
removeLineItem: () => {},
updateLineItem: () => {},
}