Skip to content

Blocking and Non-blocking APIs

As of version 6.0 of the Backendless SDK for JavaScript, all Backendless APIs are available only in the non-blocking (Promise-based) implementation. The APIs methods return a Promise object, see the Mozila doc or Google's primer for the details on the JavaScript Promise API. The Promise API is supported and enabled by default, mostly in all modern browsers. If you want to support older browsers, consider using polyfill.

Consider the example below - non-blocking user registration:

function userRegistered( user ) {
    console.log( "user has been registered" );
}

function gotError( err ) {
    console.log( "error message - " + err.message );
    console.log( "error code - " + err.statusCode );
}

var user = new Backendless.User();
user.email = "backendlessdeveloper@backedless.com";
user.password = "password";
Backendless.UserService.register(user).then(userRegistered).catch(gotError);

Important

Using non-blocking APIs in web apps is considered a good practice. Blocking APIs are not recommended for the following reasons:
1. Blocking APIs may lead to inferior user experience such as non-responsive UI.
2. Modern web browsers mark blocking XHR requests as 'deprecated' and report usage warnings in the browser's console.