首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Laravel在控制器中附加额外数据和自定义响应

Laravel在控制器中附加额外数据和自定义响应
EN

Stack Overflow用户
提问于 2019-02-13 19:16:07
回答 1查看 440关注 0票数 0

我正在调用一个在我的laravel控制器中的函数。我使用了laravel的自定义响应来返回数据。但是一些其他的数据被添加到我的回复中,即使我没有添加它。

代码语言:javascript
复制
return Response::make(json_encode(array(
    'error' => false, 
    'message' => 'Redaction done successfully.', 
    'is_redacted' => 0)), 200, 
    array(
    'Content-Type' => 'application/json'
    )
);

上面是我添加的用于返回响应的代码。但我收到的回复是:

代码语言:javascript
复制
    > * Found bundle for host redaction-stage-tcm.tylerhost.net: 0x55998c67ee40
    * Re-using existing connection! (#0) with host redaction-stage-tcm.tylerhost.net
    * Connected to redaction-stage-tcm.tylerhost.net (208.64.239.110) port 443 (#0)
    > POST /ocr/OCRWeb/v2/Documents('mfr_8')/OCRWeb.Scan HTTP/1.1
    Host: redaction-stage-tcm.tylerhost.net
    User-Agent: GuzzleHttp/6.3.3 curl/7.43.0 PHP/5.6.11-1ubuntu3.4
    OData-Version: 4.01
    OData-MaxVersion: 4.01
    Content-Type: application/json
    Content-Length: 2
    upload completely sent off: 2 out of 2 bytes
    < HTTP/1.1 200 
    < Cache-Control: no-transform
    < Cache-Control: no-cache
    < Cache-Control: no-store
    < Cache-Control: must-revalidate
    < Cache-Control: max-age=0
    < Expires: Thu, 01 Jan 1970 00:00:00 GMT
    < Vary: *
    < Pragma: no-cache
    < X-Clacks-Overhead: GNU Terry Pratchett
    < OData-Version: 4.01
    < Preference-Applied: 
    < Content-Type: application/json; odata.metadata=minimal
    < Content-Length: 163
    < Date: Wed, 13 Feb 2019 10:44:40 GMT
    < 
    * Connection #0 to host redaction-stage-tcm.tylerhost.net left intact
    {"error":false,"message":"Redaction done successfully.","is_redacted":0}

我在我的函数中调用了一些rest API。此数据与此相关,但为什么它会附加到我的自定义响应中??请帮我拿一下。

EN

回答 1

Stack Overflow用户

发布于 2019-02-13 20:17:29

尝尝这个,

代码语言:javascript
复制
return response()->json([
   'error' => false, 
   'message' => 'Redaction done successfully.', 
   'is_redacted' => 0, 
   'Content-Type' => 'application/json'
], 200)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54668886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档