The summer has been really busy and we’ve dusted off the JS SDK, stripping out large parts of its legacy. Parse.Promises and Backbone style callbacks are definitely out.

Why the move now you may ask?

Well, we’re also working hard on parse-server version 3.0, which revamps the cloud code API. The Cloud Code ‘callbacks’ have always been in the form: response.success('yay'); and response.error('oops');.

The response object is following the backbone style callback form, with success and error callbacks. The next generation of Cloud Code will get rid of this interface that belongs to another age. In 2018, async functions and Promise are part of the JavaScript language, available in the LTS node runtime, and not only the leading edge.

What should I do?

  • If you’re still relying on backbone style callbacks with the JavaScript SDK, your code will break. You will need to replace backbone style success/error callbacks with Promises.

  • If you’re using Parse.Promise the migration to 2.0 should be quick and painless as Parse.Promise was mostly compatible with the native Promise interface.

In both cases, you’ll need to spend some time making sure your code still works as expected. If you have unit tests, it’s also time to update them!

It’s a lot of work, should I really move to SDK 2.0?

Yes you should! You’ll remove many lines, making your code more readable.

Take the following example:

function loginAndGetFeed(username, password, callback) {
  Parse.User.logIn(username, password, {
    success: function(user) {
      const query = new Parse.Query('Feed');
      query.find({
        success: function(feed) {
          callback(null, feed);
        },
        error: function(error) {
          callback(error);
        }
      })
    },
    error: function(error) {
      callback(error);
    }
  })
}

With the modern SDK you get the equivalent with just a fraction of the lines:

async function loginAndGetFeed(username, password,) {
  await Parse.User.logIn(username, password);
  return new Parse.Query('Feed').find();
}

I’m sold. How do I get started?

We have written a migration guide that will help you along the way. As always, do not hesitate to open an issue.

When parse-server version 3.0 gets out, it will ship with this 2.0 version of the JS SDK.

We hope you enjoy this update which truly brings the Parse JS SDK to 2018’s standards!

Florent Vilmart,