Skip to content
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

Need help with usage #17

Open
RapahelS opened this issue Jan 2, 2022 · 7 comments
Open

Need help with usage #17

RapahelS opened this issue Jan 2, 2022 · 7 comments

Comments

@RapahelS
Copy link

RapahelS commented Jan 2, 2022

Hello,
I am trying to use the amazon-paapi.
If I call the paapi and print the result to the terminal, I am getting following response.
exports { ItemsResult: exports { Items: [ [exports] ] } }

How can I get and use the api response?
Do you have an example that shows how to call the code and how to get the result in json format?

@RapahelS
Copy link
Author

RapahelS commented Jan 2, 2022

Sorry. I forgot to mention that I am trying to use the searchItems example

@hardcore
Copy link

Hello,

I use Marketplace www.amazon.de (Germany) and I have the same problem :-(

Hope someone can help us!

Thanks a lot!

@jorgerosal
Copy link
Owner

Hi, were you able to get a solution? If you could send your code here so we can check? Thanks!

@RapahelS
Copy link
Author

Yes, I found a solution.
This is the code I ended up using:

amazonPaapi.js

`const amazonPaapi = require("amazon-paapi");

const commonParameters = {
AccessKey: "XXXXXXX",
SecretKey: "XXXXXXX",
PartnerTag: "XXXXXX",
PartnerType: "Associates",
Marketplace: "www.amazon.de",
};

let requestParameters = {
SearchIndex: "All",
ItemCount: 5,
Resources: [
"Images.Primary.Large",
"ItemInfo.Title",
"Offers.Listings.Price",
"Offers.Listings.Availability.Type",
"CustomerReviews.StarRating",
"BrowseNodeInfo.BrowseNodes.SalesRank",
"ItemInfo.Features",
"ItemInfo.ProductInfo",
"ItemInfo.TechnicalInfo",
],
};

exports.getItemsFromAmazonByKeyword = (productsArray) => {
return new Promise(async (resolve) => {
requestParameters.Keywords = productsArray;
try {
let data = await amazonPaapi.SearchItems(
commonParameters,
requestParameters
);
resolve(data);
} catch (error) {
console.log("paapi Error: " + error);
reject(error);
}
});
};`

app.js

...
`async function searchProductsByKeyword(keyword) {
let data = await AmazonUtils.getItemsFromAmazonByKeyword(keyword);

return data;
}`
...

Please let me know if there is a more elegant way.

@marco910
Copy link

@RapahelS I'm having the same issue. How did you manage the import of getItemsFromAmazonByKeyword in app.js?

@EliaTolin
Copy link

I'm having the same issue. Have you fix?

@tka85
Copy link

tka85 commented Sep 23, 2023

Using console.log directly on the response object does not display the full structure because contains nested objects, possibly with non-enumerable properties.

To better inspect the entire response object, you need to use JSON.stringify() to convert the object into a readable string format. Use this instead:

console.log(JSON.stringify(data, null, 2));

This did it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants