I need to convert a Laravel
Edit Profile
form page to React
(Partially), I am using react-hook-form
for the Edit Profile
page form
, the form
has an onsubmit ajax call
( POST api/v1/user/profile/edit
) that needs to be authorized with the authorization header
with access token
, the access token is generated by Laravel Passport
like:
public function login( LoginRequest $request )
{
// Parameter(s)
$data = [
'email' => $request->email,
'password' => $request->password,
];
// Login & Return User Model
$user = $this->users->login( $data );
// Create + Get Access Token
$access_token = $user->createToken('user_access_token', [])
->accessToken;
// Transform Result
$result = $this->loginTransformer->transform( $user );
// RETURN Result
return $this->sendResponse($result, trans('api.user.login_success'))
->header('Authorization', 'Bearer '.$access_token);
How do I pass the Laravel Passport
access token
from Laravel
to the frontend React component
?