Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log from external function #3

Open
xkubow opened this issue Aug 5, 2021 · 2 comments
Open

Log from external function #3

xkubow opened this issue Aug 5, 2021 · 2 comments

Comments

@xkubow
Copy link

xkubow commented Aug 5, 2021

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);
}

@whaliendev
Copy link

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.

@whaliendev
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants