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

isSimpleObject breaks onGet when Object.toString() fails #149

Open
adunofaiur opened this issue Jun 26, 2018 · 0 comments
Open

isSimpleObject breaks onGet when Object.toString() fails #149

adunofaiur opened this issue Jun 26, 2018 · 0 comments

Comments

@adunofaiur
Copy link

Howdy,

Thank you for this awesome project !

We ran into a bug when attempting to return a value from an intercepted get call. Our return data is fairly complicated and includes several large 2D arrays of floats.

Axios checked to see if our object was simple, and called Object.toString(), which failed. This caused a Type Error to propagate outside of axios.

We were able to resolve the issue by putting the toString code into a try catch like this:

function isSimpleObject(value) {

  try {

    return value !== null && value !== undefined && value.toString() === '[object Object]';

  } catch (e) {

    return false;

  }
}

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

1 participant