laravel - How can I send multiple parameters in return response json in Laravel?
问题描述
I want to send multiple parameters in return function of laravel with json like this
$var1='value1';
$var2='value2';
return response()->json($var1, $var2);```
解决方案
send it in array
return response()->json([$value1, $value2]);
Another way.
You need to add use Response;
Only then you can successfully retrieve your data with
$data = [$value1, $value2];
return Response::json($data);
you can pass status as well.
return Response::json($data,200);
推荐阅读
- html - CSS Grid - 如何让溢出仅在中间行(3 行网格)上工作?
- html - 悬停时的 SVG 不进行过渡
- java - Java - for 循环相关查询
- r - 打印 add1() 的进度报告
- java - 当我尝试在 recyclerview 中搜索时,我在代码中做错了什么?
- ios - (iOS) viewport-fit=cover 元标记不能完美地与导航栏配合使用
- python - Sqlite“OperationalError:靠近“05”:语法错误”
- database - SQLite:从路径列表创建目录结构表
- reactjs - 异步等待未通过 onupload 进度回调捕获 401 axios
- nltk - 使用 NLTK 以三列格式读取自定义语料库以进行 pos 标记