This is a playground
to test code. It runs a full Node.js
environment and already has all of npm
’s 400,000 packages pre-installed, including ocapi-client
with all npm
packages installed. Try it out:
require()
any package directly from npmawait
any promise instead of using callbacks (example)This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
__________________________________________________________________
, / ,
----__----__----__------__------------__---/--------__----__--_/_-
/ ) / ' / ) / ) / / ' / / /___) / ) /
_(___/_(___ _(___(___/___/_/_______(___ _/___/___(___ _/___/_(_ __
/
/
ShopApi - JavaScript client for Salesforce OCAPI shop api.
To publish the library as a npm, please follow the procedure in "Publishing npm packages".
Then install it via:
npm install ocapi-client --save
If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:
npm install GIT_USER_ID/GIT_REPO_ID --save
The library also works in the browser environment via npm and browserify. After following
the above steps with Node.js and installing browserify with npm install -g browserify
,
perform the following (assuming main.js is your entry file):
browserify main.js > bundle.js
Then include bundle.js in the HTML pages.
Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:
module: {
rules: [
{
parser: {
amd: false
}
}
]
}
Please follow the installation instruction and execute the following JS code:
import ShopApi from 'ocapi-client'
ShopApi.ApiClient.instance = new ShopApi.ApiClient({
clientUsername: 'YOUR USERNAME', // Configure HTTP basic authorization: customers_auth
clientPassword: 'YOUR PASSWORD', // Configure HTTP basic authorization: customers_auth
oAuthAccessToken: '' // Configure OAuth2 access token for authorization: oauth2_application
})
const api = new ShopApi.BasketsApi()
const basketId = "basketId_example" // {String} the id of the basket to be retrieved
api.deleteBasketsByID(basketId)
.then(() {
console.log('API called successfully.')
})
.catch((fault) => {
console.error(fault)
})