Skip to content

Cannot read property 'http' of undefined #18

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

Closed
gutenye opened this issue Jul 15, 2015 · 5 comments
Closed

Cannot read property 'http' of undefined #18

gutenye opened this issue Jul 15, 2015 · 5 comments
Assignees
Labels

Comments

@gutenye
Copy link

gutenye commented Jul 15, 2015

When I use it like

var DSHttpAdapter = require("js-data-http")
var adapter = new DSHttpAdapter()

I got

node_modules/js-data-http/dist/js-data-http.js:140
        this.http = options.http || axios;
@jmdobry
Copy link
Member

jmdobry commented Jul 15, 2015

What version are you using?

@gutenye
Copy link
Author

gutenye commented Jul 16, 2015

2.0.0

@MarkHerhold
Copy link

I am having the exact same issue. js-data-http v2.0.0. Tested on io.js v3.0.0 and node 0.12.7 for good measure.

@MarkHerhold
Copy link

It looks like this can be simply fixed by modifying the example code above (copied from the README) to include an options object.

var DSHttpAdapter = require("js-data-http")
var adapter = new DSHttpAdapter({})

Passing in undefined as the options argument is not a common use-case though because users need to specify their API's basePath. I can't see how DSHttpAdapter can do anything without this information. I think js-data-http should throw an error if the user fails to specify an object to the DSHttpAdapter constructor. It should also throw an error if the user fails to specify the basePath inside the said object.

I would also modify the README to have:

var DSHttpAdapter = require("js-data-http")
var adapter = new DSHttpAdapter({ basePath: "http://[address here]/" })

@jmdobry
Copy link
Member

jmdobry commented Aug 13, 2015

I'll take a look when I have a development comp again.

@jmdobry jmdobry added the bug label Sep 20, 2015
@jmdobry jmdobry self-assigned this Sep 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants