My addon has the following lines, working fine on EE 6:
$http = (new Http())
->withOptions(['base_uri' => ee('Config')->get('my_api').'/'])
->withToken(ee('Config')->get('my_token'))
->acceptJson();
$response = $http->post($endpoint, $data);
ee()->output->set_status_header($response->status(), $response->reason());
ee()->output->send_ajax_response($response->json(), $response->status());
Now, if the status code is 422, I receive the following on the frontend:
{
"error": "No status text available. Please check your status code number or supply your own message text."
}
Changing the status code to anything else works.