I'm using Gazzle 6 with Laravel 5.1 and I'm having a strange behaviour returning my data from the APIs I'm using. This is my code:
$data = array(
'id' => '112233'
);
$from = \Carbon\Carbon::now()->subDays(1)->format('d/m/Y');
$to = \Carbon\Carbon::now()->subMonths(1)->format('d/m/Y');
$first_report = $this->client->post('http://ift.tt/1HJjTo9', [
'auth' => ['myemail@email.com', 'mypassword'],
'form_params' => ['data' => json_encode($data)]
]);
$second_report = $this->client->get('http://ift.tt/1N6nc5M', [
'query' => [
'account_auth_token' => '000011122223333444455556667778889999',
'start_date' => $to,
'end_date' => $from
]
]);
return array(
'first_report' => $first_report,
'second_report' => $second_report
);
If I return the data as an array like the previous one the first_report and second_report are empty. But if I return only for example
return $first_report;
or
return $second_report;
The data is returned correctly for each report but I don't know what is the issue there, because I have tried with: json_encode or even return $response()->json... but still not working.
Do you have any idea about what's going on?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire