From 228090ad83de32ce5e7dcfda982c88f601a57cc6 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 6 Jan 2024 16:37:44 +0100 Subject: [PATCH] ajax: use Object.entries --- assets/javascripts/lib/ajax.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/assets/javascripts/lib/ajax.js b/assets/javascripts/lib/ajax.js index 2445cc96..809b7472 100644 --- a/assets/javascripts/lib/ajax.js +++ b/assets/javascripts/lib/ajax.js @@ -59,14 +59,12 @@ var serializeData = function (options) { }; var serializeParams = (params) => - (() => { - const result = []; - for (var key in params) { - var value = params[key]; - result.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`); - } - return result; - })().join("&"); + Object.entries(params) + .map( + ([key, value]) => + `${encodeURIComponent(key)}=${encodeURIComponent(value)}`, + ) + .join("&"); var applyCallbacks = function (xhr, options) { if (!options.async) {