Closed toknT closed 5 years ago
Hi
I actually do not recommend this kind of approach, because it creates redundancy with two sources of truth - 1) The HTTP response code 2) Your code response in the content of the response
You should ideally use the http response code for all situations.
However if you really want to do this, the best approach to take is to have a "BaseTransformer" which all your other transformers are extended from, and that you use by default, and in that base transformer, you just add that parameter to the response (so that it's there every time).
To do this you will probably need to pass it to the transformer from all your controllers, which is again why I think it is not a good approach.
@specialtactics thanks your replay, I found the solution
data
key https://github.com/dingo/api/issues/1047#issuecomment-227355001
2 . set content in response event https://github.com/dingo/api/issues/1224#issuecomment-372601557And really agree with your not add message
and code
in success response ,But it's our team 's requirement.
Great @toknT - good to hear !
How to add
message
, 'code' in success response ?Digno return
message
,code
when go error,But how can I add they to a success response?