t3chnoboy / amazon-product-api

:credit_card: Amazon Product Advertising API client
365 stars 104 forks source link

Error: [ { Code: [Object], Message: [Object] } ], #71

Open Zorrow2008 opened 7 years ago

Zorrow2008 commented 7 years ago

Hello,

I implemented this meteor package and I am getting this error message.

I20170110-20:50:42.011(-8)? title:Building Java Programs
I20170110-20:50:42.012(-8)? author:Stuart Reges
I20170110-20:50:42.248(-8)? { '$': { xmlns: 'http://ecs.amazonaws.com/doc/2013-08-01/' },
I20170110-20:50:42.248(-8)? Error: [ { Code: [Object], Message: [Object] } ],
I20170110-20:50:42.248(-8)? RequestId: [ 'a5d13542-51ec-4868-9662-172160dc4001' ] }

Why is this occuring? Any help would be appreciated.

t3chnoboy commented 7 years ago

Hi! Can you please provide some more info and post the code?

Zorrow2008 commented 7 years ago

I am building a Meteor application that will take a search input from the user and use Amazon's itemSearch operation to find and return information about the book( I would like its ISBN, title, and author for now).

I created a Meteor method to do so and when the user enters submit on the search form ,I believe I call the method.

Here is my meteor method code:

Meteor.methods({
    itemSearch(title, author) {
        console.log("title:" + title);
        console.log("author:" + author);
        client.itemSearch({
            title: title,
            author: author,
            searchIndex: 'Books',           
            responseGroup: 'ItemAttributes,Offers,Images,Small'
        }).then(function(results){
          console.log(results);
        }).catch(function(err){
          console.log(err);
        });
    }
});

Here is my javascript code in response to a user submitting the search form:

Template.bookSearch.events({
    'submit form' ( event, template ) {
        event.preventDefault();
        var title = event.target.title.value;
        var author = event.target.author.value;
        console.log("title = " + title);
        console.log("author = " + author);
        Meteor.call( 'itemSearch', title, author, ( error, response ) => {
          if ( error ) {
            Bert.alert( error.reason, 'danger' );
          } else {
            Bert.alert( 'itemSearch was called', 'success' );
          }
        });  
    }   
})

I am getting the alert saying that itemSearch was called successfully, so I think I am accessing the api . I don't understand what the error message I'm getting means however.

t3chnoboy commented 7 years ago

The code looks good. Can you make sure the credentials are valid? Can you also print the full error object? That would be very helpful. Here's how you can do it http://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-jss-console-log-rather-than-object