大家好,如何将耗时请求中的数据存储到数据库中?
我的handle函数中有一些数据。
public function handle(Request $request)
{
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.github.com/repos/unified/learning-laravel');
$jsonArray = json_decode($res->getBody()->getContents(), true);
// dd($jsonArray);
}
当我转储$ jsonArray时,我从该请求中获得了一些数据。
在我的路线上:Route::post('iaccs-hook','WebhookController@store');
在我的控制器中:
public function store(Request $request){
$api = new Client([
'base_uri' => 'https://github.com',
'cookies' => true,
]);
$response = $api-get('https://api.github.com/repos/unified/learning-laravel');
$mydata = json_decode($response->getBody()->getContents());
$object = new Webhook();
$object->COUNTRY = $mydata->COUNTRY;
$object->SPADOC_CD = $mydata->SPADOC_CD;
$object->ORBITAL_TBA = $mydata->ORBITAL_TBA;
$object->save();
dd($object);
}
但是我遇到了这个错误:错误405
非常感谢。