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

Object type checking might fail in nuxt applications #652

Closed
LucidityDesign opened this issue Mar 3, 2022 · 5 comments · Fixed by #654
Closed

Object type checking might fail in nuxt applications #652

LucidityDesign opened this issue Mar 3, 2022 · 5 comments · Fixed by #654
Assignees

Comments

@LucidityDesign
Copy link

LucidityDesign commented Mar 3, 2022

For response objects coming from nuxt-axios the test for obj.constructor === Object (as it is used here) fails.

Also see nuxt-community/axios-module#565

Can we use a more robust logic to check for objects?

@wopian
Copy link
Owner

wopian commented Mar 3, 2022

Does obj instanceof Object work for nuxt-axios as your demo repository does not build with modern OpenSSL versions (3.x) for me

@LucidityDesign
Copy link
Author

LucidityDesign commented Mar 4, 2022

I tried several checks I found on StackOverflow:

test.data instanceof Object => false
typeof test.data => "object"
test.data.constructor.name => "Object"
Object.prototype.toString.call(test.data) => "[object Object]"
Object.getPrototypeOf(test.data) === Object.prototype => false
test.data => {userId: 1, id: 1, title: 'delectus aut autem', completed: false}

I will have another look at the axios module (see my findings here)
I can start the demo with OpenSSL 3.0.1

@wopian
Copy link
Owner

wopian commented Mar 4, 2022

I'll switch them to typeof 👍

@LucidityDesign
Copy link
Author

LucidityDesign commented Mar 4, 2022

Thanks. Keep in mind, that null and Arrays also return 'object'
Check for Array and null is already implemented :)

@wopian
Copy link
Owner

wopian commented Mar 4, 2022

Released as 9.1.25 and 10.0.0-alpha.22

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

Successfully merging a pull request may close this issue.

2 participants