lundi 25 mai 2020

Laravel: ErrorException: Trying to get property of non-object

I keep getting ErrorException: Trying to get property of non-object in a Job I am running.
I am running:

$appData = $this->getAppData()

if ($appData->pending_validation) {
 //
}

public function getAppData()
{
    $apiKey = env('APP_SETUP_KEY');
    $client = new Client(['x-api-key'=> $apiKey]);

    $response = $client->request(
        'GET',
        'https://apps.customendpoint.com/app',
        [
            'headers' => [
                'x-api-key' => $apiKey,
            ],
        ]);

    return $response->getBody()->getContents();
}

The error is occuring on $appData->pending_validation but when I go to log $appData, I get: {"blocked":true,"pending_validation":true}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire