facebook / react-native

A framework for building native applications using React

Home Page:https://reactnative.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

superagent recommendation does not actually work

vishnevskiy opened this issue · comments

In the network section of the docs it recommends using superagent but when you npm install and require it you end up seeing something like this.

"Unexpected end of script"

https://www.dropbox.com/s/xcixxwmwrkhn2ly/Screenshot%202015-03-27%2015.18.40.png?dl=0

Removing the require resolves it.

It appears to be an issue with the debug module dependency of superagent. The module has incorrectly determined that it is running in a node environment and is throwing an error.

But you're right, I'm seeing the same error.

I actually tried importing superagent/lib/client directly and it resulted in the same problem.

Hi!
You can try 'superagent/lib/client' but you need to modify require statements at the top of file:
var Emitter = require('component-emitter');
var reduce = require('reduce-component');
Because React Native doesn't correctly handle 'browser' section in package.json.

Also you can try my fork that is work with React Native:
https://github.com/philipshurpik/superagent
It has some other little fixes...

The packager now looks at the browser field. superagent should be usable once they publish a new version following this PR ladjs/superagent#621 which just makes it not depend on a location object on the global object.