A simple Vanilla JS Library and API
jDrupal...
// Connect to Drupal and say hello to the current user.
jDrupal.connect().then(function() {
var user = jDrupal.currentUser();
var msg = user.isAuthenticated() ?
'Hello ' + user.getAccountName() : 'Hello World';
alert(msg);
});
// Load a node and display the title.
jDrupal.nodeLoad(123).then(function(node) {
alert(node.getTitle());
});
// Login and show the user their id.
jDrupal.userLogin('bob', 'secret').then(function() {
alert(jDrupal.currentUser().id());
});
// Get results from a view and print the node ids to the console.
jDrupal.viewsLoad('my-view-url').then(function(view) {
var results = view.getResults();
for (var i = 0; i < results.length; i ++) {
var node = new jDrupal.Node(results[i]);
console.log('node id: ' + node.id());
}
});
// Connect to Drupal and say hello to the current user.
system_connect({
success: function(result) {
var msg = Drupal.user.uid == 0 ?
'Hello World' : 'Hello ' + Drupal.user.name;
alert(msg);
}
});
// Load a node and display the title.
node_load(123, {
success: function(node) {
alert(node.title);
}
});
// Login and show the user their id.
user_login("bob", "secret", {
success: function(result) {
alert(Drupal.user.id);
}
});
For complete details, refer to the docs for jDrupal 8 or jDrupal 7.