saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.03k stars 105 forks source link

Connector object() throws an exception but json returns null|object? #418

Closed Braunson closed 3 months ago

Braunson commented 3 months ago

When attempting to get the data from a connector's request, we can use ->json() which will return null if it fails/nothing is available. However if we use ->object() it will throw an exception on error.

Shouldn't the object() method also follow the same expectation as json()? I would expect a null/empty array response instead of an exception.

Secondly any reason we cannot provide a key/default in the object like we do with json() and array()?

If this is something that the maintainer feels is necessary. I can put in a PR for it.

Sammyjo20 commented 3 months ago

Fixed in #420 thanks for the PR @Braunson !