How to solve the problem when laravel GuzzleHttp directly reports an error when the interface returns 404?

  1. use GuzzleHttp to send a post request, and the returned data is 404 , resulting in a link status of 404 ;
  2. .
  3. then laravel will report back in the form of an error. How to make him not report an error?
  4. Code:
  $response = $http->post($url, $http_param);

error report:

Client error: `POST http://******` resulted in a `404 Not Found` response: {"code":0,"desc":"","timestamp":"20180426114652","data":"eyJlcnJvckNvZGUiOjQwNCwiZXJyb3JNc2ciOiJOb3QgRm91bmQifQ==" (truncated...)
  1. Note that the error report is made by laravel . It is useless for me to use try () {} catch () {} , but it will be reported back in the form of laravel error report.
  2. I don"t want him to report an error, I just want to get the 404 data returned;
  3. how to solve it?
Mar.05,2021

you can use try () {} catch () {} 404 to catch errors with GuzzleHttp\ Exception\ RequestException , document

Menu