diff --git a/frontend/src/Store/Actions/releaseActions.js b/frontend/src/Store/Actions/releaseActions.js index 898b27eb9..024045657 100644 --- a/frontend/src/Store/Actions/releaseActions.js +++ b/frontend/src/Store/Actions/releaseActions.js @@ -243,6 +243,7 @@ export const actionHandlers = handleThunks({ url: '/release', method: 'POST', contentType: 'application/json', + dataType: 'json', data: JSON.stringify(payload) }).request; diff --git a/frontend/src/Store/Actions/searchActions.js b/frontend/src/Store/Actions/searchActions.js index cd8a15d92..f27046354 100644 --- a/frontend/src/Store/Actions/searchActions.js +++ b/frontend/src/Store/Actions/searchActions.js @@ -115,6 +115,7 @@ export const actionHandlers = handleThunks({ const promise = createAjaxRequest({ url: '/author', method: 'POST', + dataType: 'json', contentType: 'application/json', data: JSON.stringify(newAuthor) }).request; @@ -153,6 +154,7 @@ export const actionHandlers = handleThunks({ const promise = createAjaxRequest({ url: '/book', method: 'POST', + dataType: 'json', contentType: 'application/json', data: JSON.stringify(newBook) }).request; diff --git a/frontend/src/Utilities/createAjaxRequest.js b/frontend/src/Utilities/createAjaxRequest.js index b47b957f2..0f025d74c 100644 --- a/frontend/src/Utilities/createAjaxRequest.js +++ b/frontend/src/Utilities/createAjaxRequest.js @@ -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);