1.2.4 • Published 9 years ago

cosmicjs-browser v1.2.4

Weekly downloads
2
License
ISC
Repository
github
Last release
9 years ago

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

});
1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago