Fix regression in fetchConfiguration
This commit is contained in:
parent
8b110020e1
commit
8081e7fee9
1 changed files with 1 additions and 4 deletions
|
@ -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();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue