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

Would it be possible to have a node "http.request" implementation? #5

Closed
chrislf opened this issue May 30, 2017 · 2 comments
Closed

Comments

@chrislf
Copy link

chrislf commented May 30, 2017

I have some code which uses fetch, and would like to run automated tests on it. But fetch is a browser technology (c.f JakeChampion/fetch#184 (comment)) and CLI tests are easiest run via node (AFAIK).

How feasible would it be to have another implementation with the same interface, which uses node's http client underneath?

Thanks for all your work so far!

@glennsl
Copy link
Contributor

glennsl commented May 30, 2017

Hi! I'm not sure why you'd want that, since the comment you link to explains well why doing so would be a bad idea. There'd be subtle semantic differences, so you wouldn't really be able to trust your tests anyway. Additionally, support for node out of the box would at the very least require another layer of indirection, which would significantly increase the amount of code having to be shipped to browsers, adding cost to the primary use case.

But bs-fetch really isn't much more than an interface itself, it doesn't ship with any actual implementation, not even a polyfill, so I think you should be able to just `require('isomorphic-fetch)' to get node support.

Alternatively, as I learned today, there's bs-axios. Though personally I'd just abstract away the low-level IO myself and mock it at a higher level.

I hope this helps, even if it might not be quite what you wanted. I'll go ahead and close this, but feel free to ask any follow-up questions :)

@glennsl glennsl closed this as completed May 30, 2017
@chrislf
Copy link
Author

chrislf commented May 30, 2017

Thank you: isomorphic-fetch does what I need. I'll read up on bs-axios as well, that looks interesting.

Thanks again!

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