我必须做一个API调用更新购物车,但更新后,它没有渲染到支付页面从控制器索引函数
API.PHP
Route::post('cart',[Controller::class, 'index']);控制器
public function index(){
// updating values
return view('payment');
}WEB.PHP文件
Route::get('/payment', function () {
return view('payment');
});发布于 2021-06-12 23:34:42
您应该先检查来自API的响应。根据响应,您可以执行活动。在您的情况下,您可以使用以下方法。
public function index(){
try {
//$response = API::functionName($requestData);
if ($response === 'success') {
//redirect to payment page
} else {
//same page with error message;
}
} catch (\Throwable $th) {
dd($th->__toString());
}
}https://stackoverflow.com/questions/67949090
复制相似问题