我的需求是封装一个json数据,代码如下:
//封装用户错误码
protected function errCode($type = '') {
switch ($type) {
case 'success':
$code = 4001001;
$retData = array('code'=>$code);
break;
default:
$code = 4004009;
$msg = '非法请求';
$retData = array('code'=>$code,'msg'=>$msg);
break;
}
return response()->json($retData);
}
最终也是能输出结果的,只是带了一些头部信息,我应该如何将头部信息隐藏呢?返回结果如下:
HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Type: application/json
{"code":4004009,"msg":"\u975e\u6cd5\u8bf7\u6c42"}