Welcome Guest, Not a member yet? Register   Sign In
Query return empty CSP object when wrapped?

(This post was last modified: 10-13-2021, 01:05 AM by blaasvaer. Edit Reason: Fucked up editor! )

If I do this in my controller:

PHP Code:
return $this->response->setJSON($this->model->find($id)); 

I properly get the data I want as an object:

    "id": "3",
    "name": "my item",
    "meta": null,
    "created_at": "2020-12-22 15:19:50",
    "updated_at": null,
    "deleted_at": null

But if I wrap it like this:

PHP Code:
$response = array();

$response["data"] = $this->response->setJSON($this->model->find($id)); // exactly as the above

$response["fields"] = $this->model->getFieldData$resource );


I get this:

  "data": {
    "CSP": {} <-- why this empty object all of a sudden?
  "fields": [ < this data is fine > ]

Why the empty CSP object all of a sudden?

I tried enabling CSP in the Config/App.php but that didn't change a thing ... and to be honest I don't like the 'random' character this has to it.

NOTE: And by the way; this editor has serious problems when formatting and previewing posts ... al content gets scrambled and tons of new lines get added. It's basically a nightmare to use. I usually have to use a text editor and copy/paste and reformat everything everytime I make an edit to a post. Someone gonna fix this at some point?

Weeeeeeell, that made perfectly sense. I should remove the 'response' part when adding it to an array ... sigh!

Change this:
PHP Code:
$response["data"] = $this->response->setJSON($this->model->find($id)); 

To this:
PHP Code:
$response["data"] = $this->model->find($id); 

Messages In This Thread
Query return empty CSP object when wrapped? - by blaasvaer - 10-13-2021, 12:38 AM

Theme © iAndrew 2016 - Forum software by © MyBB