Skip to content

Commit

Permalink
Fixed: Settings fields being altered during save
Browse files Browse the repository at this point in the history
[common]
Fixes #5871
  • Loading branch information
Qstick committed Feb 7, 2021
1 parent b0753ab commit dd61480
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.Radarr.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 dd61480

Please sign in to comment.