Per indicar que demanem un json (diferenciar petició web de petició api):
X-Requested-With : 'XMLHttpRequest'
o també:
'Accept' => 'application/json',
Exemple:
config.headers['X-Requested-With'] = 'XMLHttpRequest';
On posar el token, per exemple capçalera Authorization:
'Authorization' => 'Bearer ' . $accessToken,
Axios té una forma de configurar les Request amb un objecte config:
https://github.com/mzabriskie/axios#request-config
Es poden també utilitzar interceptors:
When calling routes that are protected by Passport, your application's API consumers should specify their access token as a Bearer token in the Authorization header of their request. For example, when using the Guzzle HTTP library:
$response = $client->request('GET', '/api/user', [ 'headers' => [ 'Accept' => 'application/json', 'Authorization' => 'Bearer '.$accessToken, ], ]);
Resources: