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

揚(yáng)帆大魚(yú)
TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個(gè)贊
你那里有雙重 }} ,嘗試刪除它,這樣它就會(huì)像這樣:
Route::get('/getLocation/{postalCode}', function () {
$response = Http::get('https://theapi');
return $response->json();
});
編輯:
將路由參數(shù)添加到API函數(shù)參數(shù)中
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 關(guān)注
- 96 瀏覽
添加回答
舉報(bào)
0/150
提交
取消