Level 1
You could try the following Laravel 5.3+:
public function index(Request $request) {
...
if($request->expectsJson()) {
return response()->json($data);
}
...
}
It looks like the function is wantsJson is Laravel 5.0-5.2
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've also tried curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
Please or to participate in this conversation.