Answers for "encode in laravel api"

PHP
0

encode in laravel api

//In base controller
protected function jsonResponse($data, $code = 200)
{
    return response()->json($data, $code,
        ['Content-Type' => 'application/json;charset=UTF-8', 'Charset' => 'utf-8'], JSON_UNESCAPED_UNICODE);
}
//In your controller
$this->jsonResponse($data);
Posted by: Guest on March-01-2021

Browse Popular Code Answers by Language