amrshawky / laravel-currency

Laravel package for current and historical currency exchange rates & crypto exchange rates. based on the free API exchangerate.host
MIT License
332 stars 44 forks source link

Methods return "Null" #3

Closed nMckenryan closed 3 years ago

nMckenryan commented 3 years ago

Hi, Thanks for compiling this package!

I'm running through a Laravel Tutorial that uses your package (https://www.youtube.com/watch?v=dHPcWbC62R4) but I'm running into a persistent issue.

I've tried to run the:

Currency::convert()
        ->from('USD')
        ->to('EUR')
        ->get();

Method, but it returned 'null'. I've tried a combination of other methods, such as ->amount(40) but it yields the same result.

I cloned and installed the 'master' repo that the tutorial is based on (Repo Here: https://github.com/codewithdary/laravel-currency-converter) and it yields the same problem. I've installed all the dependencies through composer but i seem to get the same result.

I see that this package uses an API, just wanted to verify that this connection is still active?

amrshawky commented 3 years ago

Hi,

Maybe it's a certificate issue, try chaining the withoutVerifying() method like this:

Currency::convert()
        ->from('USD')
        ->to('EUR')
        ->withoutVerifying()
        ->get();

If this doesn't work, you always can enable throwing Exceptions to know what is exactly wrong.

Let me know how it goes.

nMckenryan commented 3 years ago

Thanks for getting back to me so quickly. Adding withoutVerifying() has fixed it. Fantastic! Thanks very much!