mirror of
https://github.com/inventree/InvenTree.git
synced 2026-02-06 05:15:52 +00:00
refactor(frontend): load server and auth info in paralell (#11245)
This commit is contained in:
@@ -37,18 +37,19 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
|||||||
server: emptyServerAPI,
|
server: emptyServerAPI,
|
||||||
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
|
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
|
||||||
fetchServerApiState: async () => {
|
fetchServerApiState: async () => {
|
||||||
|
await Promise.all([
|
||||||
// Fetch server data
|
// Fetch server data
|
||||||
await api
|
api
|
||||||
.get(apiUrl(ApiEndpoints.api_server_info))
|
.get(apiUrl(ApiEndpoints.api_server_info))
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
set({ server: response.data });
|
set({ server: response.data });
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.error('ERR: Error fetching server info');
|
console.error('ERR: Error fetching server info');
|
||||||
});
|
}),
|
||||||
|
|
||||||
// Fetch login/SSO behaviour
|
// Fetch login/SSO behaviour
|
||||||
await api
|
api
|
||||||
.get(apiUrl(ApiEndpoints.auth_config), {
|
.get(apiUrl(ApiEndpoints.auth_config), {
|
||||||
headers: { Authorization: '' }
|
headers: { Authorization: '' }
|
||||||
})
|
})
|
||||||
@@ -57,7 +58,8 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
|||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.error('ERR: Error fetching SSO information');
|
console.error('ERR: Error fetching SSO information');
|
||||||
});
|
})
|
||||||
|
]);
|
||||||
},
|
},
|
||||||
auth_config: undefined,
|
auth_config: undefined,
|
||||||
auth_context: undefined,
|
auth_context: undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user