
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@moltin/request
Advanced tools
[](https://www.npmjs.com/package/@moltin/request) [](https://github.com/semantic-r
🎮 Minimal Moltin API request library for Node
yarn add @moltin/request # npm install @moltin/request
const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'
const client = new MoltinClient({
client_id: '...'
})
client
.get('products')
.then(console.log)
.catch(console.error)
⚠️ You should not use client credentials on the client-side. You will expose your client secret, read more about authentication here.
const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'
const client = new MoltinClient({
client_id: '...',
client_secret: '...'
})
client
.post('brands', {
name: 'My Special Brand',
slug: 'my-special-brand',
status: 'live'
})
.then(console.log)
.catch(console.error)
client
.put('brands/:id', {
name: 'My Special Brand!'
})
.then(console.log)
.catch(console.error)
client
.delete('brands/:id')
.then(console.log)
.catch(console.error)
To prevent unnecessary authentication requests, you will want to use a storage adapter.
const { MoltinClient } = require('@moltin/request')
const NodeStorageAdapter = require('@moltin/node-storage-adapter')
const client = new MoltinClient({
client_id: '...',
storage: new NodeStorageAdapter('./localStorage')
})
client
.get('products')
.then(console.log)
.catch(console.error)
This library uses cross-fetch to make requests. If you wish to change this library, you can pass a custom fetch when instantiating a new moltin client.
const { MoltinClient } = require('@moltin/request')
const fetchEverywhere = require('fetch-everywhere')
const client = new MoltinClient({
client_id: '...',
fetch: fetchEverywhere
})
client
.get('products')
.then(console.log)
.catch(console.error)
const { MoltinClient } = require('@moltin/request')
// import { MoltinClient } from '@moltin/request'
const client = new MoltinClient({
client_id: '...',
client_secret: '...',
fetch: customFetch,
storage: new NodeStorageAdapter('./moltin'),
host: '...',
version: '...',
application: '...',
currency: '...',
customer_token: '...',
headers: {
// ...
}
})
The Moltin API provides you the ability to send various request headers that change the way data is stored or retrieved.
By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type
header as an additional argument to get
, post
, put
and delete
.
This argument can be used to get products by enabled currency, language or even use for uploading files to Moltin.
Note: If you add the Content-Type
custom header to post
, put
or delete
you will need to encode data
yourself.
const { MoltinClient } = require('@moltin/request')
const client = new MoltinClient({
client_id: '...'
})
const headers = {
'X-Moltin-Currency': 'gbp'
}
client
.get('products', headers)
.then(console.log)
.catch(console.error)
The examples below demonstrate how you connect this library with other frameworks and tools.
FAQs
[](https://www.npmjs.com/package/@moltin/request) [](https://github.com/semantic-r
We found that @moltin/request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.