How to get a value from the response of External Laravel API? 1



If you are using Guzzle HTTP to call an API in Laraval:


           $client = new \GuzzleHttp\Client();

            $response = $client->request('POST', '');


use the following code to get a response in JSON or to print a value of a key:


          $data = json_decode($response->getBody(), true);

            echo $data['name'];


To print complete response use the following code:


echo $response->getBody();