I have this code that was working correctly for me, which basically is a call to an api with a user and a password, to get a TOKEN:
$client1 = new Client(['cookies' => true]);
$headers1 = array('Content-Type: application/x-www-form-URLencoded');
$body1='username=zzzzzzz1&password=zzzzzzz2';
$promises1['MITOKEN']= $client1->postAsync('https://unaurldeunaapi',
['headers' => $headers1,'body' => $body1,'verify' => false,'timeout'
=> 0.2]);
$results1 = Promise\settle($promises1)->wait();
and what brought me results here:
$token=$results1['MITOKEN']['value']->getHeaderLine('Location');
Suddenly this error appears:
'Undefined index: value',
/var/www/vhosts/xxxx.com/api.xxxx.com/app/Http/Controllers/ApiController.php ', 79, array (' client1 '= > object (Client),' continue '= > 1, 'headers1' = > array ('Content-Type: application / x-www-form-URLencoded'), 'body1' = & 'username = zzzzzzz1 & password = zzzzzzz2', 'promises1' = & gt ; array ('MITOKEN' = > object (Promise)), 'results1' = > array ('MITOKEN' = > array ('state' = > 'rejected', 'reason' = > object (ConnectException )))))
specifically:
array('state' => 'rejected', 'reason' => object(ConnectException)))))
Separate topic, probe the api with Postman (REST client for tests), and everything works ok, generating the token that I need
I do not understand the error well, I will appreciate help.