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

Not usable on browser #288

Closed
roccomuso opened this issue Mar 26, 2017 · 5 comments
Closed

Not usable on browser #288

roccomuso opened this issue Mar 26, 2017 · 5 comments

Comments

@roccomuso
Copy link

The simplest example doesn't work on a browser:

got.get(url)
	.then(function(response){
		console.log(response.body);
		//=> '<!doctype html> ...'
	})
	.catch(function(error){
		console.log(error.response.body);
		//=> 'Internal server error ...'
	});

Replacing the global setImmediate fixed it:

window.setImmediate = setTimeout;

@alextes
Copy link
Contributor

alextes commented Apr 1, 2017

I guess this is our 'we want got in the browser!' issue.
Fair enough, I don't see one yet.
I think #89 and #128 are two big blockers.
Making this step first could be smart. From what I can tell from ava/#24, set-immediate-shim or p-immediate are options to solve this.

I can read-up on what the actual problem is, or someone can raise a green flag and I can open a PR and do some testing by hand (#128 looks hard).

@kevva
Copy link
Contributor

kevva commented May 21, 2017

I'm using this in the browser without any problems using babel-runtime and babel-plugin-transform-runtime but I've used set-immediate-shim in the past by doing window.setImmediate = require('set-immediate-shim');.

@mcjohnalds
Copy link

While got does work in the browser, it uses ES6 syntax along with some of its dependencies, which means you have to add some of your node_modules directories to babel's includes to work in the browser. Though I wouldn't recommend this as it increases build time and breaks easily.

@ghost
Copy link

ghost commented Sep 20, 2017

How about on react-native? Is it possible to implement there?

@kevva
Copy link
Contributor

kevva commented Sep 20, 2017

@transifex3, that's better asked on StackOverflow. I.e. "how to use node modules in React Native". Also try searching for answers on Google. There's https://github.com/staltz/react-native-node too.

Going to close this issue in favour of #128.

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