执行代理后出现
{message: "Call to a member function post() on null",…}
exception:"Symfony\Component\Debug\Exception\FatalThrowableError"
file:"C:\laragon\www\api\app\Http\Proxy\TokenProxy.php"
line:34
message:"Call to a member function post() on null"
代码如下:
public function proxy($grantType,array $data=[])
{
$data=array_merge($data,[
'client_id' =>env('PASSPORT_CLIENT_ID'),
'client_secret' =>env('PASSPORT_CLIENT_SECRET'),
'grant_type' =>$grantType,
]);
$response =$this->http->post('/oauth/token',[ // 这是提示的第 34行代码
'form_params' => $data
]);
$token =json_encode((string) $response->getBody(),true);
return $response()->js([
'token' => $token['access_token'],
'expires_in' => $token['expires_in']
])->cookie('refreshToken',$token['refreshToken'],1296000,null,null,false,true);
}