首页 > 解决方案 > 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);```

标签: laravel

解决方案


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);

推荐阅读