Closed maulikkanani closed 9 years ago
Unfortunately, i don't see another way to do this because the status code is only available into the response class.
However, i strongly discourage you to that this way. Your API client MUST always check status code from HTTP Header. You are not suppose to get it from the body.
If you really need to do that, create you a new response class extending EllipseSynergie\ApiResponse\AbstractResponse
and create you a custom service provider if you using Laravel.
Hello ,
We will need to add status code in to the response.
Like public function withArray(array $array, array $headers = array()) { // $code = $this->statusCode; if ($this->statusCode == '200') { $array = array('code' => $this->statusCode , 'success' => TRUE) + $array; } else { $array = array('code' => $this->statusCode, 'success' => FALSE) + $array; } return response()->json($array, $this->statusCode, $headers); }
For now, we had modified library code on "ellipsesynergie/api-response/src/Laravel/Response.php".
But I feel. Its not good way.
Could you please suggest me how can i add this to all response without change library code ?
Or Is there any way to add the status code from controller for final response.
Actually, we will need final response like "http://screencast.com/t/nmWF7PYU".
Please help us on this.
Thanks,