joedawson / amazon-ecs

With Laravel, search and lookup Amazon products easily.
MIT License
52 stars 26 forks source link

Call to undefined method json() #6

Open isbkch opened 8 years ago

isbkch commented 8 years ago

Doing a simple: $bookFromAmazon = Amazon::lookup($bookTitle)->json(); throws an error: Call to undefined method GuzzleHttp\Psr7\Response::json()do you have any idea why ?

PS: ->xml()gives the same error

joedawson commented 8 years ago

@isbkch what version of Laravel are you using? Thanks!

isbkch commented 8 years ago

I'm using 5.2 It turned out this error was thrown when Lookup desn't find any results. It works just fine when I have results :)

joedawson commented 8 years ago

Thanks for letting me know @isbkch I'll try get a fix in for that as soon as possible.

leinad952003 commented 7 years ago

Same problem here!.. Also l5.2 Anything new on the matter?

Thanks! :)

joedawson commented 7 years ago

Will be taking a look at it this weekend, thanks for your patience.

BillDavid07 commented 7 years ago

Hi, any updates on this issue? thanks. :)

joedawson commented 7 years ago

No updates yet, still not found the time to sit down and work through this. If anyone does have time, feel free to submit a PR for review.

brino commented 7 years ago

I've run into this same issue ... sometimes (like when amazon returns 400 "bad request" or a 503 "rate limit" response) a Guzzle/PSR7/Response object is returned by the Amazon::search(), which does not have a json() method. In this case you must call something like $response->getReasonPhrase() or $response->getStatusCode() to detect and return some sort of error message to the user.

What is odd is that the AmazonECS object is somehow being replaced by the Guzzle Response object within the facade when the search() method returns.

iglabsolute commented 6 years ago

@JoeDawson I get the same issue as @brino & @leinad952003 -- Has anyone found a solution for this?

iglabsolute commented 6 years ago

Resolved by updating AmazonECS.php

Lines 64 & 85..

Change: ClientException To: ClientErrorResponseException