Formatting REST response in JSON |
So, I'm trying to follow the docs here:
https://codeigniter.com/user_guide/incom...stful.html In my extended ResourceController I'm setting $format = 'json', but I always get XML. I've run through the code of ResourceController.php, ResponseTrait.php and Negotiate.php and I can see nowhere where this property is actually used to decide the response format! As it stands it seems like the headers are always used to determine the response. Can anyone confirm or explain where I may have messed up? Here's the relevant code: <?php namespace App\Controllers; use CodeIgniter\RESTful\ResourceController; class Salutation extends ResourceController { protected $modelName = 'App\Models\SalutationModel'; protected $format = 'json'; public function index() { // print '<pre>'; print_r($this->model->asArray()->findAll()); exit; // $this->setFormat("json"); return $this->respond($this->model->findAll()); } |
Messages In This Thread |
Formatting REST response in JSON - by neilpopham - 11-04-2020, 07:51 AM
RE: Formatting REST response in JSON - by neilpopham - 11-04-2020, 10:23 AM
RE: Formatting REST response in JSON - by neilpopham - 11-05-2020, 06:28 AM
|