aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/xtext/fetchBackendConfig.ts
blob: 71ff2e635406345fc490b3688732dd37f2c66a6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */

import BackendConfig, { ENDPOINT } from './BackendConfig';

export default async function fetchBackendConfig(): Promise<BackendConfig> {
  const configURL = `${import.meta.env.BASE_URL}${ENDPOINT}`;
  const response = await fetch(configURL);
  const rawConfig = (await response.json()) as unknown;
  return BackendConfig.parse(rawConfig);
}