Fixed: Error on bulk delete from queue

pull/1064/head
ta264 4 years ago
parent 3ab29eee60
commit eb9b9d57ed

@ -243,6 +243,7 @@ export const actionHandlers = handleThunks({
url: '/release', url: '/release',
method: 'POST', method: 'POST',
contentType: 'application/json', contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(payload) data: JSON.stringify(payload)
}).request; }).request;

@ -115,6 +115,7 @@ export const actionHandlers = handleThunks({
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/author', url: '/author',
method: 'POST', method: 'POST',
dataType: 'json',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(newAuthor) data: JSON.stringify(newAuthor)
}).request; }).request;
@ -153,6 +154,7 @@ export const actionHandlers = handleThunks({
const promise = createAjaxRequest({ const promise = createAjaxRequest({
url: '/book', url: '/book',
method: 'POST', method: 'POST',
dataType: 'json',
contentType: 'application/json', contentType: 'application/json',
data: JSON.stringify(newBook) data: JSON.stringify(newBook)
}).request; }).request;

@ -7,18 +7,6 @@ function isRelative(ajaxOptions) {
return !absUrlRegex.test(ajaxOptions.url); 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) { function addRootUrl(ajaxOptions) {
ajaxOptions.url = apiRoot + ajaxOptions.url; ajaxOptions.url = apiRoot + ajaxOptions.url;
} }
@ -32,7 +20,7 @@ function addContentType(ajaxOptions) {
if ( if (
ajaxOptions.contentType == null && ajaxOptions.contentType == null &&
ajaxOptions.dataType === 'json' && ajaxOptions.dataType === 'json' &&
(ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST')) { (ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST' || ajaxOptions.method === 'DELETE')) {
ajaxOptions.contentType = 'application/json'; ajaxOptions.contentType = 'application/json';
} }
} }
@ -52,7 +40,6 @@ export default function createAjaxRequest(originalAjaxOptions) {
const ajaxOptions = { ...originalAjaxOptions }; const ajaxOptions = { ...originalAjaxOptions };
if (isRelative(ajaxOptions)) { if (isRelative(ajaxOptions)) {
moveBodyToQuery(ajaxOptions);
addRootUrl(ajaxOptions); addRootUrl(ajaxOptions);
addApiKey(ajaxOptions); addApiKey(ajaxOptions);
addContentType(ajaxOptions); addContentType(ajaxOptions);

Loading…
Cancel
Save