
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
cosmicjs-browser
Advanced tools
The official Javascript client for Cosmic JS on the browser. This module helps you easily add dynamic content to your website or application
Go to https://cosmicjs.com, create an account and setup a bucket.
npm install cosmicjs-browser
/* Configure
================================ */
var config = {};
config.bucket = {
slug: 'client-example',
read_key: '', // add read_key if added to your Cosmic JS bucket settings
write_key: '' // add write_key if added to your Cosmic JS bucket settings
};
/* Get bucket
================================ */
Cosmic.getBucket(config, function(err, bucket){
// do something with the bucket
});
/* Get objects
================================ */
Cosmic.getObjects(config, function(err, objects){
// do something with objects
});
/* Get media
================================ */
Cosmic.getMedia(config, function(err, media){
// do something with media
});
/* Add object
================================ */
var object = {
"write_key": config.bucket.write_key,
"type_slug": "pages",
"title": "Test Title",
"content": "Test Content"
};
Cosmic.addObject(config, object, function(err, object){
// say hi to your new object
});
/* Edit object
================================ */
var object = {
"write_key": config.bucket.write_key,
"slug": "test-title",
"type_slug": "pages",
"title": "New Title",
"content": "New Content"
};
Cosmic.editObject(config, object, function(err, object){
// say hi to your edited object
});
/* Delete object
================================ */
var object = {
"write_key": config.bucket.write_key,
"slug": "test-title"
};
Cosmic.deleteObject(config, object, function(err, object){
// say goodbye to your object
});
FAQs
The official Javascript client for Cosmic JS on the browser. This module helps you easily add dynamic content to your website or application
We found that cosmicjs-browser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.