I am trying to get (StatusCode) in response to a REST api, while its just the name of the returned field and an error message like this
[{"field":"Email","message":"Email \" ali@ali.ali \" has already been taken."}]
I added an answer
'response' => [ 'class' => 'yii\web\Response', 'on beforeSend' => function ($event) { $response = $event->sender; if ($response->data !== null && Yii::$app->request->get('suppress_response_code')) { $response->data = [ 'success' => $response->isSuccessful, 'data' => $response->data, ]; $response->statusCode = 200; } }, ],
source share