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

Return value of Osiset\BasicShopifyAPI::jsonDecode() must be an instance of stdClass, null returned #67

Closed
ianfortier opened this issue Apr 27, 2020 · 4 comments
Assignees

Comments

@ianfortier
Copy link

Catch this in my Sentry logs, sometimes Shopify seems to return null.
Maybe can we add something to catch the null in $this->jsonDecode($body);

Symfony\Component\Debug\Exception\FatalThrowableError: Return value of Osiset\BasicShopifyAPI::jsonDecode() must be an instance of stdClass, null returned
#19 /vendor/osiset/basic-shopify-api/src/Osiset/BasicShopifyAPI.php(1004): Osiset\BasicShopifyAPI::jsonDecode
#18 /vendor/osiset/basic-shopify-api/src/Osiset/BasicShopifyAPI.php(832): Osiset\BasicShopifyAPI::Osiset\{closure}
#17 /vendor/osiset/basic-shopify-api/src/Osiset/BasicShopifyAPI.php(868): Osiset\BasicShopifyAPI::rest
@gnikyt
Copy link
Owner

gnikyt commented May 3, 2020

@ianfortier Which osiset/basic-shopify-api version are you on? Check with composer info.
I recently released a new version last week and it doesn't have a type return because it could be stdClass or array now, previously it was just stdClass.

@gnikyt gnikyt self-assigned this May 3, 2020
@ianfortier
Copy link
Author

"osiset/basic-shopify-api": "^8.1"

Will try to update to 8.2

@khiconit
Copy link

khiconit commented Jun 5, 2020

Why you are return array instead stdClass ? @osiset

[ 'errors' => false, 'response' => $resp, 'status' => $resp->getStatusCode(), 'body' => $this->toResponse($resp->getBody()), 'link' => $link, 'timestamps' => $this->getTimeStore()->get($this->getSession()), ]

I familiar stdClass more than array. Because I was used your package from 6.0 version
LOL
:D

@gnikyt
Copy link
Owner

gnikyt commented Jun 18, 2020

@khiconit It was changed because there was several people using this package with my other repository (laravel-shopify) and trying to map the responses to a Laravel JSON Resource, this is not possible with a stdClass.

The main return of rest/graph will return an array now instead of stdClass. However, the "body" of the response can be accessed as an array or stdClass.

Will close for now unless present in 8.2+.

@gnikyt gnikyt closed this as completed Jun 18, 2020
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

3 participants