Ribhnux / piranhax

Complete implementation package of Amazon Product Advertising API for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_isValid check is invalid

Diferno opened this issue · comments

Hi!
I'm just doing an ItemSearch and turns out that no items match my search criteria.

Although the AWS Api returns:

<Request>
    <IsValid>True</IsValid>
     <ItemSearchRequest>...</ItemSearchRequest>
     <Errors>
          <Error>
               <Code>AWS.ECommerceService.NoExactMatches</Code>
               <Message>We did not find any matches for your request.</Message>
          </Error>
     </Errors>
</Request>

Piranhax tells me that the request is invalid and therefor the promise fails. Can't tell if it failed because of an error on the request or just because my search found no results.

Shouldn't it take into account the IsValid field and show the error message in case of erros and not just reject?

Thanks in advance

What is the value of TotalResults?

In their documentation, Amazon states that:

Although an IsValid value of True specifies that the request was valid and executed, it does not mean that a result was obtained. There may not have been any items that satisfied the search criteria, for example. To check for this condition, either search for the presence of an Error element, or evaluate the value of the TotalItems element. If the value is zero, there are no results to display, as shown in the following example.

http://docs.aws.amazon.com/AWSECommerceService/latest/GSG/CheckingRequestExecution.html

Should it excluded from exception or not? What do you think?

Because, exception raised when a request got non success response, or there are some errors in response. And promise will reject it.

I will investigate in detail, and consider the best solution for this.

TotalResults = 0

It was a search returning no values and was trying to handle it on the then part of the promise, but was going nuts because it's thrown to the catch.
From my point of view, the request should be invalid if the field IsValid is set to false, otherwise is valid but there can be either results to show or errors to handle (as in an empty search)

Thx in advance!