Open xkubow opened 3 years ago
Yes, I have the same issue. According to vue3 api refrence provide/inject:
provide and inject enables dependency injection. Both can only be called during setup() with a current active instance.
So, is there an elegant way to log from an external js file? for example, from a js file encapsulates axios requests.
Bro, you can check these two comments #1 comment and #2 comment for a solution under the current release. Hope these can help you, or maybe it's a little late.
Can't use logger outside vue. Could be provided correct type? Isn't the inject method the vue composition API?
export function logAxiosError(error: AxiosError): void { const logger = inject('vuejs3-logger') as Log; logger.error('AxiosError: ', error); }