When trying to implement this code:
import wixStoresBackend from 'wix-stores-backend'
export function getCurrentCart() {
return wixStoresBackend.getCurrentCart();
}
I am getting this error:
Cannot find module 'wix-stores-backend' in 'public/pages/spp7g.js'
I have no idea why? The website is a Store one and I do not have created this file wix-stores-backend, but I am assuming I do not need to regarding this doc.
So what is my mistake?
Had same issue with wix-users-backend. Can't use backend modules in your client-side code.
I'm not familiar with wixStores... But you use 'wix-stores' in front end.
And if you need functions from wix-stores-backend. Create a .jsw file. Write your function. And import it client side like so:
backend:
file.jsw
import wixStoresBackend from 'wix-stores-backend' export function someFunction(){ console.log('NiNiNi') }
client-side:
import { someFunction } from 'backend/file' $w.onReady(()=>{ someFunction() })
Hey,
I assume you are trying to use this code in your Code Panel and this way you will see errors when previewing your site.
As it's stated in the API, the wix-stores-backend module contains functionality for working with your site's store from backend code.
I need to create a backend file and paste this code there and now it is working