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


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

 

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

 

           $client = new \GuzzleHttp\Client();

            $response = $client->request('POST', 'https://ctells.com/tx/api/getTxFailed');

 

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();