|
|
|
@ -7,18 +7,6 @@ function isRelative(ajaxOptions) {
|
|
|
|
|
return !absUrlRegex.test(ajaxOptions.url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function moveBodyToQuery(ajaxOptions) {
|
|
|
|
|
if (ajaxOptions.data && ajaxOptions.type === 'DELETE') {
|
|
|
|
|
if (ajaxOptions.url.contains('?')) {
|
|
|
|
|
ajaxOptions.url += '&';
|
|
|
|
|
} else {
|
|
|
|
|
ajaxOptions.url += '?';
|
|
|
|
|
}
|
|
|
|
|
ajaxOptions.url += $.param(ajaxOptions.data);
|
|
|
|
|
delete ajaxOptions.data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addRootUrl(ajaxOptions) {
|
|
|
|
|
ajaxOptions.url = apiRoot + ajaxOptions.url;
|
|
|
|
|
}
|
|
|
|
@ -32,7 +20,7 @@ function addContentType(ajaxOptions) {
|
|
|
|
|
if (
|
|
|
|
|
ajaxOptions.contentType == null &&
|
|
|
|
|
ajaxOptions.dataType === 'json' &&
|
|
|
|
|
(ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST')) {
|
|
|
|
|
(ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST' || ajaxOptions.method === 'DELETE')) {
|
|
|
|
|
ajaxOptions.contentType = 'application/json';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -52,7 +40,6 @@ export default function createAjaxRequest(originalAjaxOptions) {
|
|
|
|
|
const ajaxOptions = { ...originalAjaxOptions };
|
|
|
|
|
|
|
|
|
|
if (isRelative(ajaxOptions)) {
|
|
|
|
|
moveBodyToQuery(ajaxOptions);
|
|
|
|
|
addRootUrl(ajaxOptions);
|
|
|
|
|
addApiKey(ajaxOptions);
|
|
|
|
|
addContentType(ajaxOptions);
|
|
|
|
|