update fetch requests

This commit is contained in:
Luke Pulverenti 2015-12-06 14:46:18 -05:00
parent 5f6d68e3b5
commit 7c3fa06651
10 changed files with 74 additions and 39 deletions

View file

@ -196,7 +196,7 @@
} else {
fetchRequest.body = paramsToString(request.data);
contentType = contentType || 'application/x-www-form-urlencoded';
contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8';
}
}
@ -208,6 +208,21 @@
return fetch(request.url, fetchRequest);
}
function paramsToString(params) {
var values = [];
for (var key in params) {
var value = params[key];
if (value !== null && value !== undefined && value !== '') {
values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
}
}
return values.join('&');
}
/**
* Wraps around jQuery ajax methods to add additional info to the request.
*/
@ -407,21 +422,6 @@
});
};
function paramsToString(params) {
var values = [];
for (var key in params) {
var value = params[key];
if (value !== null && value !== undefined && value !== '') {
values.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
}
}
return values.join('&');
}
/**
* Creates an api url based on a handler name and query string parameters
* @param {String} name