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
var config = {};
config.bucket = {
slug : 'client-example',
read_key : '',
write_key : ''
};
Cosmic.getObjects(config, function(err, objects){
});
Cosmic.getMedia(config, function(err, media){
});
var object = {
"write_key" : config.bucket.write_key,
"type_slug" : "pages",
"title" : "Test Title",
"content" : "Test Content"
};
Cosmic.addObject(config, object, function(err, 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){
});
var object = {
"write_key" : config.bucket.write_key,
"slug" : "test-title"
};
Cosmic.deleteObject(config, object, function(err, object){
});