Level 11
public function index()
{
$client = new GuzzleHttp\Client();
$res = $client->request('GET','https://api.employees.net/allemployees?key=fgfdhsddddDDDDD')->getBody();
$clientdatas = json_decode($res, true);
...
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In my Laravel-5.8, I am trying to consume API end point GET Request with Guzzle:
use App\Employee;
use App\Department;
public function index()
{
$client = new GuzzleHttp\Client();
$res = $client->request('GET','https://api.employees.net/allemployees')->getBody();
$clientdatas = json_decode($res, true);
...
}
The API has subscription key.
In POSTMAN, I did it this way and it works:
GET https://api.employees.net/allemployees?key=fgfdhsddddDDDDD
How do I add the subscription key to my Laravel api
public function index()
{
$client = new GuzzleHttp\Client();
$res = $client->request('GET','https://api.employees.net/allemployees')->getBody();
$clientdatas = json_decode($res, true);
...
}
Thank you.
public function index()
{
$client = new GuzzleHttp\Client();
$res = $client->request('GET','https://api.employees.net/allemployees?key=fgfdhsddddDDDDD')->getBody();
$clientdatas = json_decode($res, true);
...
}
Please or to participate in this conversation.