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

How to check axiosInstance instanceof axios? #737

Closed
xarnze opened this issue Mar 3, 2017 · 1 comment
Closed

How to check axiosInstance instanceof axios? #737

xarnze opened this issue Mar 3, 2017 · 1 comment

Comments

@xarnze
Copy link

xarnze commented Mar 3, 2017

Hi,

Does anyone know if it's possible to check if an object is an instance of axios? e.g.

var axios = require(axios);

var axiosInstance = axios.create();

if(axiosInstance instanceof axios){
// do something
}

@rubennorte
Copy link
Member

Not sure why it was done the way it is, but axios is not a class/constructor and axios.create doesn't return an instance of it.

I recommend you to check the existence of a specific interface (like the request function) instead of using instanceof that could have a weird behaviour in some contexts.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants