Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed: Settings fields being altered during save
(cherry picked from commit dd61480)
  • Loading branch information
Qstick committed Feb 7, 2021
1 parent 510b0bd commit 21d7d81
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions frontend/src/Utilities/createAjaxRequest.js
Expand Up @@ -28,6 +28,15 @@ function addApiKey(ajaxOptions) {
ajaxOptions.headers['X-Api-Key'] = window.Lidarr.apiKey;
}

function addContentType(ajaxOptions) {
if (
!ajaxOptions.contentType &&
ajaxOptions.dataType === 'json' &&
(ajaxOptions.method === 'PUT' || ajaxOptions.method === 'POST')) {
ajaxOptions.contentType = 'application/json';
}
}

export default function createAjaxRequest(originalAjaxOptions) {
const requestXHR = new window.XMLHttpRequest();
let aborted = false;
Expand All @@ -46,6 +55,7 @@ export default function createAjaxRequest(originalAjaxOptions) {
moveBodyToQuery(ajaxOptions);
addRootUrl(ajaxOptions);
addApiKey(ajaxOptions);
addContentType(ajaxOptions);
}

const request = $.ajax({
Expand Down

0 comments on commit 21d7d81

Please sign in to comment.