From 5b2e57b1950055986fc2374ee27533005b8ce7ab Mon Sep 17 00:00:00 2001 From: Alessandro Sebastiani Date: Tue, 22 Sep 2020 13:05:27 +0200 Subject: [PATCH] fix: remote validation was not working correctly using url param and load by url --- src/app/utils/calls.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app/utils/calls.js b/src/app/utils/calls.js index 04e7737f..2e0d3cee 100644 --- a/src/app/utils/calls.js +++ b/src/app/utils/calls.js @@ -29,10 +29,11 @@ export const passRemoteURLToValidator = yamlURL => { return fetch(`${url}?${paramsString}`, myInit) .then(res => { - if (! res.ok) { + // 422 should pass as it indicates a failed validation + if (! res.ok && res.status != 422) { throw new Error(`fetch(${url}) returned ${res.status}`); } - res.text() + return res.text() }); }; @@ -56,9 +57,9 @@ export const postDataForValidation = data => { return fetch(url, myInit) .then(res => { - if (! res.ok) { + if (! res.ok && res.status != 422) { throw new Error(`fetch(${url}) returned ${res.status}`); } - res.text() + return res.text() }); };