Fix regression in fetchConfiguration
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Siklos 2022-08-04 18:32:40 +02:00
parent 8b110020e1
commit 8081e7fee9

View file

@ -127,7 +127,6 @@ export class App extends React.Component<IAppProps> {
*/ */
export async function fetchConfiguration(): Promise<Configuration> { export async function fetchConfiguration(): Promise<Configuration> {
const url = `${import.meta.env.VITE_API_URL}`; const url = `${import.meta.env.VITE_API_URL}`;
// The test library cannot use the Fetch API // The test library cannot use the Fetch API
// @ts-ignore // @ts-ignore
if (window.fetch) { if (window.fetch) {
@ -138,15 +137,13 @@ export async function fetchConfiguration(): Promise<Configuration> {
response.json() response.json()
) as Configuration; ) as Configuration;
} }
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', url, true); xhr.open('POST', url, true);
xhr.onreadystatechange = function() { // Call a function when the state changes. xhr.onreadystatechange = function() { // Call a function when the state changes.
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) { if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
resolve(JSON.parse(this.responseText)); resolve(JSON.parse(this.responseText));
} }
reject(xhr.responseText);
}; };
xhr.send(); xhr.send();
}); });