1

I want to send multiple parameters in return function of laravel with json like this

$var1='value1';
$var2='value2';
return response()->json($var1, $var2);```

2 Answers 2

5

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);
Sign up to request clarification or add additional context in comments.

Comments

1
  $var['value1']='value1';
  $var['value2']='value2';
  return response()->json([$var]);

you can also do it this way

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.