我有這條路線Route::get('/getLocation/{postalCode}', function () { $response = Http::get('https://theapi'); return $response->json();});遺憾的是這不起作用我可以通過以下方式訪問 apihttps://theapi?PostalCode=xxxx我如何在上班途中復制這一點?
1 回答

揚帆大魚
TA貢獻1799條經驗 獲得超9個贊
你那里有雙重 }} ,嘗試刪除它,這樣它就會像這樣:
Route::get('/getLocation/{postalCode}', function () {
$response = Http::get('https://theapi');
return $response->json();
});
編輯:
將路由參數添加到API函數參數中
Route::get('/getLocation/{postalCode}', function ($postalCode) {
// do whatever you want to postalCode variable
$response = Http::get('https://theapi', [
'PostalCode' => $postalCode
]);
return $response->json();
});
- 1 回答
- 0 關注
- 99 瀏覽
添加回答
舉報
0/150
提交
取消