-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST JSONP response serialization #10943
Labels
Comments
As a solution I add new property in
and then change
Fin
|
👍 if (($callback = Yii::$app->request->get('callback')) !== null) {
$response->content = sprintf('%s(%s);', $callback, Json::htmlEncode($response->data));
} elseif ($response->data !== null) {
$response->content = '';
Yii::warning("The 'jsonp' response requires that jsonpCallback parameter to be set", __METHOD__);
} |
Also prefer to split |
Issue moved to yiisoft/yii-api#8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use JSONP as a response format when creating REST API:
But actual response is serialized ActiveProvider:
A problem orrurs in
yii\rest\Serializer
, whichserialize()
method don't understand['data' => $data, 'callback' => $callback]
format and return data without serialization.The text was updated successfully, but these errors were encountered: