fetchlogic / amz-products

Amazon Product Advertising API Wrapper
Apache License 2.0
15 stars 4 forks source link

Not really an issue... more of a question #4

Open chadhumphrey opened 8 years ago

chadhumphrey commented 8 years ago

Greetings, I'm using your amz-products and I'm new to Node.js. I'm able to get the app up and running, however I'm banging my head on how parse the json object (returned from amazon). I have done it plenty of times in php / javascript. Don't know why any node.js is giving me such a headache. Any chance you good throw out an example in "do something with the response here". This seems to work but this is as far as I can get. console.log(JSON.stringify(res,null,2));

amazon.getItemsInBrowseNode({ BrowseNode: 1234566 }, function(err, res){ //do something with the response here });

Thanks in advance.

joshtronic commented 8 years ago

@jwd2a may be able to clarify a bit, but I think you need to be parsing the result:

try {
  resObj = JSON.parse(res);
} catch (e) {
  // FUUUUUUUUUU...
}
chadhumphrey commented 8 years ago

Maybe this will help somebody, or not... ;)

But I got what I needed using the inspect package.

var util = require('util');`

amazon.getItemsInBrowseNode({
BrowseNode: 1234566
}, function(err, res){
var t = util.inspect(res.ItemLookupResponse.Items.Item.DetailPageURL, false, null);
console.log('this is T' + t);
});