我有这条路线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 关注
- 67 浏览
添加回答
举报
0/150
提交
取消