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

Universal app #37

Closed
hrasoa opened this issue Sep 29, 2018 · 4 comments
Closed

Universal app #37

hrasoa opened this issue Sep 29, 2018 · 4 comments

Comments

@hrasoa
Copy link

hrasoa commented Sep 29, 2018

I know we should use Got for node js, but I'm building an universal app that will be rendered on both server/client side, so how should we handle that ?

@sholladay
Copy link
Collaborator

I suspect you will have an easier time Browserify-ing got than doing the inverse with ky.

@szmarczak
Copy link
Collaborator

It depends on what functionalities you are trying to implement. Got provides more functionalities than Ky because Node is a little bit more advanced. I don't recommend using a wrapper because of the differences between them. Use Got when you're targeting Node and use Ky when you're targeting browsers :)

@bkniffler
Copy link

bkniffler commented Oct 10, 2018

I think a lot of people will not be able to "just use both" since if you have a universal react app that fetches data or you write shared libraries for server and client to talk to your API, its much easier to just use axios which can be used on both sides. I don't get why it is so hard to make ky universal/isomorphic though, for node-fetch and isomorphic-fetch exists.

ky is really cool, but I'm looking for something that works everywhere :(

@sholladay
Copy link
Collaborator

@bkniffler when it comes to the basic stuff, sure, an isomorphic approach works. But I absolutely need relative URLs, which node-fetch does not support because there is no base URL there. Also, the whole concept of a Referer doesn't really work in Node. Conversely, Node has more mature support for streams since it has been around longer - the abstractions in browsers will be better when they are fully implemented, but we aren't there yet.

I think you will find that if you start using some of the more intermediate/advanced features of these HTTP clients, the isomorphic approach starts to look less and less feasible. I do believe we will get there one dsy, but it's going to take some more spec work at W3C and WHATWG first. Otherwise, libraries will just continue to fake it with lots of inconsistencies and gaps in functionality, which is the current status quo.

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

4 participants