Fix app crashing (#8076)

* fix app not being able to access shared store

* fix imports
This commit is contained in:
Nitwel
2021-09-16 15:44:18 +02:00
committed by GitHub
parent a96ce53208
commit 2fe85b519b
5 changed files with 68 additions and 97 deletions

View File

@@ -5,7 +5,7 @@ import { API_INJECT, STORES_INJECT } from '../constants';
export function useStores(): Record<string, any> {
const stores = inject<Record<string, any>>(STORES_INJECT);
if (!stores) throw new Error('[useStores]: This function has to be used inside a Directus extension.');
if (!stores) throw new Error('[useStores]: The stores could not be found.');
return stores;
}
@@ -13,7 +13,7 @@ export function useStores(): Record<string, any> {
export function useApi(): AxiosInstance {
const api = inject<AxiosInstance>(API_INJECT);
if (!api) throw new Error('[useApi]: This function has to be used inside a Directus extension.');
if (!api) throw new Error('[useApi]: The api could not be found.');
return api;
}