1
votes

I am using laravel guzzle package for get response from this https://eos.greymass.com/v1/history/get_transaction url

    $client = new Client();
    try {
        $response = $client->request('GET', 'https://eos.greymass.com/v1/history/get_transaction?id=18a20dbc34082451143c03ac54a2f24d06494d51e68f8fb1211ca0b63a53f37d');
    }catch (ClientException $e) {
        $response = $e->getResponse();
        $responseBodyAsString = $response->getBody()->getContents();
        return redirect()->back()->with('error', $responseBodyAsString);
    }
    if ($response->getStatusCode() != 200){
        return redirect()->back()->with('error', 'Status code must be 200');
    }

    $body = $response->getBody();
    return $body;

I get $body data properly, but when i tried to get $body->block_num then showing me this Undefined property: GuzzleHttp\Psr7\Stream::$block_num error

1
Have you tried debugging your $body? Your code doesn't show $body->block_num at all.andy

1 Answers

5
votes

You have to decode the $response to get it as because it will convert json into an object So for example:

$response = json_decode($client->request('GET', 'https://eos.greymass.com/v1/history/get_transaction?id=18a20dbc34082451143c03ac54a2f24d06494d51e68f8fb1211ca0b63a53f37d')->getBody(), true);

Try This! It will Help You