QuickStart

Installation

Download and place https://raw.githubusercontent.com/ClearBlade/JavaScript-API/master/ClearBlade.js inside your project directory and include it in your HTML file’s header

Usage

The ClearBlade object attaches to window after being included.

Calling ClearBlade.init(configObject) will initialize ClearBlade settings and functions and pass it as an argument to a callback.


ClearBlade.init({
	URI: 'platform address',  // e.g., 'https://platform.clearblade.com/'
	systemKey: 'theSystemKey',
	systemSecret: 'theSystemSecret',
	email: "userEmail",  // use registerEmail instead if you wish to create a new user
	password: "userPassword",
	callback: initCallback,
});

function initCallback(err, cb) {  // err is a boolean, cb has APIs and constructors attached
	if (err) {
	  throw new Error(cb);
	} else {
	  var collection = cb.collection();
	  collection.fetch(someQuery, collectionFetchCallback(err, rows) {
	  	if (err) {
		  	throw new Error(rows);
		} else {
			// do something with the collection rows
		}
	  });

	  var messaging = cb.messaging();
	  messaging.subscribe('someTopic', {timeout: 120}, subscribeCallback(err, message) {
	  	if (err) {
	  		throw new Error(message);
	  	} else {
	  		// do something with response
	  	}
  	});

	}
}

See SDK Reference for a full list of APIs