D
D
denop2020-12-09 04:37:01
Yii
denop, 2020-12-09 04:37:01

Why empty Post in YII API action?

Good time everyone!

Through Axios, I post data to a custom action. Console.log() normally prints everything before sending.
But in the controller action Yii::$app->request->post() is empty.
Rule for the action is configured like this

[
                    'class' => 'yii\rest\UrlRule',
                    'pluralize' => false,
                    'controller' => 'savedata',
                    'extraPatterns' => [
                        'POST edit' => 'edit'
                    ],
                ],


Is this normal behavior? How can this problem be solved?
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2020-12-09
@sidni

Little info. Maybe normal behavior, I think you are not sending a regular POST, but something in the form of a fashionable json.
check the setting in the config.

'request' => [
    'parsers' => [
       'application/json' => 'yii\web\JsonParser',
    ]
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question