2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-02-05 21:05:51 +00:00

refactor(frontend): load server and auth info in paralell (#11245)

This commit is contained in:
Matthias Mair
2026-02-02 22:16:17 +01:00
committed by GitHub
parent 02b10ccd75
commit 619da6e619

View File

@@ -37,27 +37,29 @@ export const useServerApiState = create<ServerApiStateProps>()(
server: emptyServerAPI,
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
fetchServerApiState: async () => {
// Fetch server data
await api
.get(apiUrl(ApiEndpoints.api_server_info))
.then((response) => {
set({ server: response.data });
})
.catch(() => {
console.error('ERR: Error fetching server info');
});
await Promise.all([
// Fetch server data
api
.get(apiUrl(ApiEndpoints.api_server_info))
.then((response) => {
set({ server: response.data });
})
.catch(() => {
console.error('ERR: Error fetching server info');
}),
// Fetch login/SSO behaviour
await api
.get(apiUrl(ApiEndpoints.auth_config), {
headers: { Authorization: '' }
})
.then((response) => {
set({ auth_config: response.data.data });
})
.catch(() => {
console.error('ERR: Error fetching SSO information');
});
// Fetch login/SSO behaviour
api
.get(apiUrl(ApiEndpoints.auth_config), {
headers: { Authorization: '' }
})
.then((response) => {
set({ auth_config: response.data.data });
})
.catch(() => {
console.error('ERR: Error fetching SSO information');
})
]);
},
auth_config: undefined,
auth_context: undefined,