Registry / ecommerce / salesive-api-axios

salesive-api-axios

JSON →
library0.0.7jsnpmunverified

Typed Axios wrappers for the Salesive Storefront API, enabling authentication, cart, wishlist, orders, products, blogs, and shipping flows. v0.0.7 is the latest stable version. It auto-resolves environment variables for Vite, Next.js, Nuxt, CRA, and Node, and stores session data in localStorage. Open source under MIT license.

npm install salesive-api-axios
INSTALL
IMPORT
SIG · SALESIVE-API-AXIOS
S
salesive-api-axios
ecommercejavascriptv0.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

auth
import { auth } from 'salesive-api-axios'
const auth = require('salesive-api-axios').auth
Named export, ESM-only.
cart
import { cart } from 'salesive-api-axios'
Named export for cart operations.
wishlist
import { wishlist } from 'salesive-api-axios'
Named export for wishlist operations.
orders
import { orders } from 'salesive-api-axios'
Named export for order operations.
coupon
import { coupon } from 'salesive-api-axios'
Named export for coupon operations.

Demonstrates typical checkout flow: ghost account creation, cart/wishlist management, OTP authentication, order creation, and coupon application.

import { auth, cart, wishlist, orders, coupon } from 'salesive-api-axios'; async function checkout() { // 1. Create a ghost customer and send OTP await auth.createGhost(); // 2. Build the cart for the shopper before authentication await cart.addItem({ productId: 'prod_123', quantity: 1 }); await cart.addItem({ productId: 'prod_456', variantId: 'variant_blue', quantity: 2, }); // 3. Add items to wishlist for later await wishlist.addItem({ productId: 'prod_789' }); // 4. Authenticate (trigger OTP flow; verify in your UI as needed) await auth.checkUser({ email }); await auth.authenticate({ email, name, phone }); await auth.verify({ email, otp }); // 5. Convert the cart into an order once authentication succeeds const { data } = await orders.createFromCart(); // 6. Optionally apply a coupon to the resulting order await coupon.apply({ orderId: data?.data?.id, code: 'SUMMER20' }); return data; }
Debug
Known issues
gotchaEnvironment variables must be prefixed correctly per framework (e.g., VITE_ for Vite, NEXT_PUBLIC_ for Next.js).
fix
Ensure your env vars match the expected prefixes; see README table.
affects: >=0.0.1
gotchaLocal storage keys are hardcoded (SALESIVE_ACCESS_TOKEN, SALESIVE_AUTH_MODE, SALESIVE_SHOP_ID). Avoid manual modification.
fix
Use provided auth methods (createGhost, verify, logout) to manage tokens.
affects: >=0.0.1
gotchaThe client uses AxiosPromise; you must handle errors with try/catch or .catch().
fix
Wrap API calls in try/catch blocks to handle network or API errors.
affects: >=0.0.1
Errors
Common errors & fixes
Module '"salesive-api-axios"' has no exported member 'auth'.
Importing from incorrect path or using default import.
fix
Use `import { auth } from 'salesive-api-axios'`.
Cannot read properties of undefined (reading 'data')
API call returned undefined without proper error handling.
fix
Wrap the call in try/catch and check response structure.
Missing SALESIVE_SHOP_ID or SALESIVE_API_KEY environment variable.
Required env vars not set.
fix
Set VITE_SALESIVE_SHOP_ID / NEXT_PUBLIC_SALESIVE_API_KEY (or other supported prefix).
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
axiosrequiredHTTP client for API requests
Agent activity
22 hits · last 30 days
node
20
Resources
salesive-api-axios — npm install salesive-api-axios · libregistry