laravel middleware for apis 1

laravel middleware for apis

$response = $client->request('POST', '/api/user', [
    'headers' => [
        'Authorization' => 'Bearer '.$token,
        'Accept' => 'application/json',
    ],
]);

Here is what the above code is Doing:
1. We’re creating a new Guzzle client.
2. We’re sending a POST request to the /api/user endpoint.
3. We’re passing the Authorization header with the token we got from the login request.
4. We’re passing the Accept header with application/json.

Similar Posts