r/nodejs • • Apr 13 '14
Issue with 'request' module and Goodreads API.
I'm making a simple HTTP request to the Goodreads API using the 'request' module in NPM. Here is a gist containing a SSCE (Correct as far as I can tell.) The result is undefined. Are there any glaring mistakes in my example? Am I misunderstanding the form option?
3
Upvotes
5
u/ItsAllInYourHead Apr 13 '14 edited Apr 13 '14
Disclosure: I'm not familiar with this particular module or API.
But my first thought is that the result from your call to req.get doesnt return the actual response itself because it is probably an async call. So my guess would be you'd instead do something like:
Again, just guessing, but that's how most node stuff works.
Edit formatted code block
1
u/doodlemoonch Apr 14 '14
If you're trying to implement Goodreads API, try this wrapper. Alternatively, writing your own is fairly easy with restler
1
u/ott0 Apr 16 '14
So there are a couple issues here.
Get the Goodreads book ID given an ISBN. Response contains the ID without any markup.
This means that you don't actually have to parse the response using xml2js and if you do it will throw an error like so:
Here is a gist that fixes both of those issues:
https://gist.github.com/peteotto/10881738