js: document utils.ajax()

This commit is contained in:
Pierre de La Morinerie 2021-07-20 17:59:55 +02:00
parent c6fff58f38
commit 7808f6dd4f

View file

@ -50,6 +50,13 @@ export function delegate(eventNames, selector, callback) {
);
}
// A promise-based wrapper for Rails.ajax().
//
// Returns a Promise that is either:
// - resolved in case of a 20* HTTP response code,
// - rejected with an Error object otherwise.
//
// See Rails.ajax() code for more details.
export function ajax(options) {
return new Promise((resolve, reject) => {
Object.assign(options, {