Fix Client Config async loading (#12308)
Fix ClientConfig async loading --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { ClientConfig } from '~/generated/graphql';
|
||||
|
||||
export const getClientConfig = async (): Promise<ClientConfig> => {
|
||||
const response = await fetch(`${REACT_APP_SERVER_BASE_URL}/client-config`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Failed to fetch client config: ${response.status} ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
|
||||
const clientConfig: ClientConfig = await response.json();
|
||||
|
||||
return clientConfig;
|
||||
};
|
||||
Reference in New Issue
Block a user