amazon-ecs icon indicating copy to clipboard operation
amazon-ecs copied to clipboard

Call to undefined method json()

Open isbkch opened this issue 9 years ago • 10 comments

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

isbkch avatar Sep 03 '16 17:09 isbkch

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

joedawson avatar Sep 03 '16 18:09 joedawson

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 :)

isbkch avatar Sep 03 '16 20:09 isbkch

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

joedawson avatar Sep 03 '16 20:09 joedawson

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

Thanks! :)

leinad952003 avatar Dec 10 '16 18:12 leinad952003

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

joedawson avatar Mar 30 '17 08:03 joedawson

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

BillDavid07 avatar Jun 10 '17 08:06 BillDavid07

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.

joedawson avatar Jun 13 '17 11:06 joedawson

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.

brino avatar Jun 20 '17 21:06 brino

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

iglabsolute avatar Dec 12 '17 04:12 iglabsolute

Resolved by updating AmazonECS.php

Lines 64 & 85..

Change: ClientException To: ClientErrorResponseException

iglabsolute avatar Dec 12 '17 04:12 iglabsolute