Is there a way to order the Craft Element-API results by the category title?
I'm just getting the error
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
The "hostingCompany" field is a category field.
'hostings.json' => [
'elementType' => Entry::class,
'criteria' => [
'section' => 'hostings',
'orderBy' => 'hostingCompany desc'
],
'paginate' => true,
'transformer' => function(Entry $entry) {
return [
'hostingDomain' => $entry->hostingDomain,
'hostingCompany' => (string)$entry->hostingCompany[0],
'url' => $entry->url,
];
},
],
Updated error message:
PHP Warning 'yii\base\ErrorException' with message 'Header may not contain more than a single header, new line detected'
in /Applications/AMPPS/www/crm.local/vendor/yiisoft/yii2/web/Response.php:380
Stack trace:
0 /Applications/AMPPS/www/crm.local/vendor/craftcms/cms/src/web/ErrorHandler.php(81): yii\base\ErrorHandler->handleError(2, 'Header may not ...', '/Applications/A...', 380)
1 [internal function]: craft\web\ErrorHandler->handleError(2, 'Header may not ...', '/Applications/A...', 380, Array)
2 /Applications/AMPPS/www/crm.local/vendor/yiisoft/yii2/web/Response.php(380): header('HTTP/1.1 404 SQ...')
3 /Applications/AMPPS/www/crm.local/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
4 /Applications/AMPPS/www/crm.local/vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response->send()
5 /Applications/AMPPS/www/crm.local/web/index.php(21): yii\base\Application->run()
6 {main}