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

TypeError: undefined is not an object (evaluating 'Request.prototype') #60

Closed
romanenko opened this issue Jan 15, 2016 · 3 comments
Closed

Comments

@romanenko
Copy link

I have a strange error happening in 1.9 PhantomJS and latest Safari environments

TypeError: undefined is not an object (evaluating 'Request.prototype')

pointing me to

if (Request.prototype.isPrototypeOf(url)) {

I use it in my test like this

import fetchMock from 'fetch-mock'
//...
fetchMock.mock('http://my.api.url/v1/example', [{ ... }])

In Chrome, Firefox everything seems to work well.
Why could it happen and are there any advices how to debug it properly?

@wheresrhys
Copy link
Owner

you probably need to polyfill fetch, and possibly Promise too https://github.com/wheresrhys/fetch-mock#troubleshooting. Let me know if that doesn't help

@romanenko
Copy link
Author

Yes, I had to polyfill fetch in Safari and PhantomJS. I'm using Karma with webpack and I had to require file with isomorphic-fetch before requiring any spec files.

Thank you very much!

@PixnBits
Copy link

I had the same error, but when using a dep package that itself used fetch (isomorphic-fetch).
The solution in my case was import/require order: be sure to load fetch-mock after anything that polyfills fetch.

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

3 participants