Comments (13)
@Codepoet77 what does the error say?
from amazon-product-api.
@Codepoet77 The field BrowseNodeId
is required to use this method.
from amazon-product-api.
I've updated this issue with the error message I see now.
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html
var express = require('express');
var router = express.Router();
var amazon = require('amazon-product-api');
router.get('/', function (req, res) {
var credentials = {
awsId: 'myId',
awsSecret: 'mySecret',
awsTag: 'myTag'
};
amazon.createClient(credentials).browseNodeLookup({}, function (err, data) {
console.log(arguments);
if (err) {
res.send(err);
}
res.send(data);
});
});
module.exports = router;
This is the error I see:
TypeError: Cannot read property '0' of undefined
at /home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/lib/index.js:28:54
at Parser. (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/lib/xml2js.js:460:18)
at Parser.emit (events.js:95:17)
at Object.onclosetag (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/lib/xml2js.js:421:26)
at emit (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/node_modules/sax/lib/sax.js:625:33)
at emitNode (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/node_modules/sax/lib/sax.js:630:3)
at closeTag (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/node_modules/sax/lib/sax.js:874:5)
at Object.write (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/node_modules/sax/lib/sax.js:1314:29)
at Parser.exports.Parser.Parser.parseString (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/lib/xml2js.js:479:31)
at Parser.parseString (/home/andrew/Documents/ppi2/source/server/node_modules/amazon-product-api/node_modules/xml2js/lib/xml2js.js:7:59)
Thanks in advance.
from amazon-product-api.
Quick update. This appears to be a legit issue.
@kauegimenes thanks for the tip. You are right I thought there was a concept of root node but it appears as though that doesnt exist and each major category is a root node. Let me know if my understanding is incorrect.
All that being said below is response that I logged in index.js. I believe the issue we are treating the a browseNodeLookup response like a Item response. The items collections does not exist it in a browse node response and is why I am still getting the exception I listed above.
index.js line 28:
results = resp[method + 'Response'].Items[0].Item;
browseNodeResponse:
{ BrowseNodeLookupResponse:
{ '$': { xmlns: 'http://webservices.amazon.com/AWSECommerceService/2011-08-01' },
OperationRequest:
[ { RequestId: [ '96085264-4de7-11e5-96d5-e745bd0a6445' ],
Arguments:
[ { Argument:
[ { '$': { Name: 'AWSAccessKeyId', Value: 'AKIAIWM6SAEG6BZXFT7Q' } },
{ '$': { Name: 'AssociateTag', Value: 'fr056-20' } },
{ '$': { Name: 'BrowseNodeId', Value: '9479199011' } },
{ '$': { Name: 'Operation', Value: 'BrowseNodeLookup' } },
{ '$': { Name: 'ResponseGroup', Value: 'BrowseNodeInfo' } },
{ '$': { Name: 'Service', Value: 'AWSECommerceService' } },
{ '$':
{ Name: 'Signature',
Value: 'pFHRNSBafAhFj8CoQETsg27MnPTFkPW/YdlNsSzx9B8=' } },
{ '$': { Name: 'Timestamp', Value: '2015-08-29T00:47:55.230Z' } } ] } ],
RequestProcessingTime: [ '0.007022995' ] } ],
BrowseNodes:
[ { Request:
[ { IsValid: [ 'True' ],
BrowseNodeLookupRequest:
[ { BrowseNodeId: [ '9479199011' ],
ResponseGroup: [ 'BrowseNodeInfo' ] } ] } ],
BrowseNode:
[ { BrowseNodeId: [ '9479199011' ],
Name: [ 'Luggage & Travel Gear' ],
Children:
[ { BrowseNode:
[ { BrowseNodeId: [ '360832011' ], Name: [ 'Backpacks' ] },
{ BrowseNodeId: [ '2204831011' ], Name: [ 'Briefcases' ] },
{ BrowseNodeId: [ '166767011' ], Name: [ 'Diaper Bags' ] },
{ BrowseNodeId: [ '2477385011' ],
Name: [ 'Fashion Waist Packs' ] },
{ BrowseNodeId: [ '15743181' ], Name: [ 'Gym Bags' ] },
{ BrowseNodeId: [ '9971584011' ], Name: [ 'Laptop Bags' ] },
{ BrowseNodeId: [ '15743251' ], Name: [ 'Luggage' ] },
{ BrowseNodeId: [ '15743231' ], Name: [ 'Messenger Bags' ] },
{ BrowseNodeId: [ '15743971' ], Name: [ 'Travel Accessories' ] },
{ BrowseNodeId: [ '15744111' ], Name: [ 'Umbrellas' ] } ] } ],
Ancestors:
[ { BrowseNode:
[ { BrowseNodeId: [ '7141124011' ],
Name: [ 'Departments' ],
IsCategoryRoot: [ '1' ],
Ancestors:
[ { BrowseNode:
[ { BrowseNodeId: [ '7141123011' ],
Name: [ 'Clothing, Shoes & Jewelry' ] } ] } ] } ] } ] } ] } ] } }
from amazon-product-api.
Was looking into this a little further and the promise works but the call back does not support browsenodelookup.
from amazon-product-api.
I'll dive into it today!
from amazon-product-api.
As mentioned before I am new Git and GitHub and was trying to learn how to fork and pull request but unfortunately need to continue to make progress on my project. This is change I made to make it work in index.js
In the call back only.
parseXML(body, function (err, resp) {
if (method === 'BrowseNodeLookup' && resp[method + 'Response'].BrowseNodes && resp[method + 'Response'].BrowseNodes.length > 0) {
results = resp[method + 'Response'].BrowseNodes[0].BrowseNode;
} else {
results = resp[method + 'Response'].Items[0].Item;
}
cb(null, results);
});
The change is I added the if block.
from amazon-product-api.
Make a pull request then! It's bloody easy!
- Fork the repo
- Change de code (make sure the tests pass with
npm test
) - Commit your changes and push it
- Go on this repo in pull request tab and create a new PR.
😊
from amazon-product-api.
This may help!
https://guides.github.com/activities/forking/
from amazon-product-api.
I suggest you to get familiar with the markdown syntaxe. It is very useful since you can use it to write issue and comment.
from amazon-product-api.
OK thanks for all the info! I think I've managed to submit a PR.
from amazon-product-api.
Travis build failed with the same errors that others have seen in the past. Do you have any insight into what got it working again? I don't believe my change caused this (as far as I know).
from amazon-product-api.
Fix in PR #23
from amazon-product-api.
Related Issues (20)
- When I import this package in a Create React App project, I get a warning for pre-built javascript file.
- Is there a way to perform similarity lookup?
- You are submitting requests too quickly. Please retry your requests at a slower rate HOT 8
- No 'Access-Control-Allow-Origin' header is present on the requested resource. HOT 8
- Amazon API returns 'Request has expired'
- How to get a product page from itemlookup HOT 3
- How to get the response in TEXT JSON? HOT 1
- How to set the product images height/width programmatically?
- How to check if product shipped to specific country ?
- Search result does not contain TotalResults and TotalPages. HOT 1
- Can I pass 'Domain" parameter in CreateClient? HOT 1
- RequestThrottled: New Efficiency-Guidelines HOT 3
- Amazon Product Advertising API 5 HOT 6
- Cannot call using API key generated for Amazon.ca. HOT 1
- I have some issue in a React /Gatsby app HOT 2
- Is this possible to use on the client side? HOT 3
- [Bug] When usign * in the power prop for ItemSearch sig is invalid
- can't find the doc
- Add query for proxy server HOT 1
- CloudKit Integration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-product-api.