data-response
data-response copied to clipboard
Is there a way to return raw data from a controller?
E.g. to return ['foo' => 'bar'] instead of
return $this->dataResponseFactory->create(['foo' => 'bar']);
In case it is, let's add corresponding configs and all the related code to documentation.
final class ApiController
{
public function actionIndex(DataResponseFactory $responseFactory)
{
$data = ['name' => 'Alex'];
return $responseFactory->createResponse($data);
}
}
Given FormatDataResponse is in your stack, you'll get the formatted object as output.