Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cosmicjs-browser

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cosmicjs-browser

The official Javascript client for Cosmic JS on the browser. This module helps you easily add dynamic content to your website or application

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Cosmic JS Logo

Cosmic JS Client for the browser

Getting started

Go to https://cosmicjs.com, create an account and setup a bucket.

Install
npm install cosmicjs-browser
Usage
/* 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

});

Keywords

FAQs

Package last updated on 26 Sep 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc