Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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;
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);
Add a comment
$var['value1']='value1'; $var['value2']='value2'; return response()->json([$var]);
you can also do it this way
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.