使用nodejs框架sails,本地和pre-prodcution环境都是正确,但是生产错误

使用 sails框架,将api的错误通过res.serverError 返回给前端,前端在调用api的catch中捕捉。在本地,部署pre环境都是ok,部署production却不能正确 读取数据。
在sails res.serverError api说明 中提示如下:

Notes
#
This method is terminal, meaning that it is generally the last line of code your app should run for a given request (hence the advisory usage of return throughout these docs).
res.serverError() (like other userland response methods) can be overridden or modified. It runs the response method defined in api/responses/serverError.js. If a serverError.js response method does not exist in your app, Sails will use the default behavior.
The specified data will be excluded from the JSON response and view locals if the app is running in the "production" environment (i.e. process.env.NODE_ENV === 'production').

修改:
没有认真查看框架,不知道是否可以通过配置来改这个错误。
只是将 res.serverError 改成 res.ok
这样前端 直接在call 的api中做个判断,读取error即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值