Socket
Book a DemoInstallSign in
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

latest
Source
npmnpm
Version
1.2.4
Version published
Maintainers
1
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

browser

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.