Browse Source

ajax: use Object.entries

Simon Legner 1 year ago
parent
commit
228090ad83
1 changed files with 6 additions and 8 deletions
  1. 6 8
      assets/javascripts/lib/ajax.js

+ 6 - 8
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) {