Socket
Socket
Sign inDemoInstall

@spree/axios-fetcher

Package Overview
Dependencies
1
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spree/axios-fetcher


Version published
Maintainers
4
Created

Readme

Source

Spree SDK in NodeJS using Axios

To use Spree SDK with Axios in NodeJS, install Axios along with the fetcher using NPM:

npm install @spree/axios-fetcher axios

Set the fetcher to axios when creating the Spree SDK client:

const createAxiosFetcher = require('@spree/axios-fetcher/dist/server/index').default
const { makeClient } = require('@spree/storefront-api-v2-sdk')
const client = makeClient({
  host: 'http://localhost:3000',
  createFetcher: createAxiosFetcher
})

Spree SDK in the browser using Axios

To use Spree SDK with Axios in the browser, include axios as a <script> tag before using the SDK:

<script src="https://unpkg.com/@spree/storefront-api-v2-sdk@6.0.0/dist/client/index.js"></script>
<script src="https://unpkg.com/axios@0.24.0/dist/axios.min.js"></script>
<script src="https://unpkg.com/@spree/axios-fetcher@1.0.0/dist/client/index.js"></script>

<script>
  const client = SpreeSDK.makeClient({
    host: 'http://localhost:3000',
    createFetcher: SpreeSDK.createAxiosFetcher.default
  })
</script>

Spree SDK will automatically detect that Axios is available and use it to make requests to Spree.

FAQs

Last updated on 01 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc