Issue
I have an API and I use that API to get the exchange rates.
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://v6.exchangerate-api.com/v6/3307b104e7b3be179b55050e/latest/USD');
$currency = $res->getBody();
I want to get the conversion_rates
data only from the JSON and ignore the rest.
I use Laravel.
Solution
might work
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://v6.exchangerate-api.com/v6/3307b104e7b3be179b55050e/latest/USD');
$data = $res->getBody()->getContents();
$dataArray = json_decode($data, true);
$rates = $dataArray['conversion_rates'] ?? [];
Answered By - abSiddique
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.