【发布时间】:2020-03-28 09:08:12
【问题描述】:
我正在尝试向示例url endpoint 发出发布请求,但我一直遇到这个奇怪的错误"The GET method is not supported for this route. Supported methods: POST." 波纹管是我的代码路由和控制器代码:
路线片段:
Route::post('/posts', 'PostController@store')->name('store');
控制器片段:
public function store(){
$client = new \GuzzleHttp\Client();
$url = "https://cdc-npin.lndo.site/api/nhtd-event/json";
$response = $client->post($url, [
'form_params' => [
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3',
'key4' => 'value4',
]
]);
dd($response
我做错了什么??
【问题讨论】:
-
错字修复,它是
dd($response);而不是dd($response -
你能把提交给这个 store 方法的表单贴出来吗?我怀疑在您访问 Guzzle 客户端之前就出现了错误