user1555112
user1555112

Reputation: 1977

cakephp 3 - return object data from a function?

I am just new to cakephp 3 and have the following issue: I am calling data from a soap source like this:

//connection to client...
$params = array('iban' => $iban);
$result = $this->client->validateIban($params);

So far so good. I can debug the result too:

debug($result->validateIban);

it returns either 'true' or 'false'.

Now I want to return the value like this:

return $result->validateIban;

But I get now the error:

Controller action can only return an instance of Response

I am now a bit lost as I don't know how to return the value? Can anyone help me out, please?

Upvotes: 0

Views: 785

Answers (1)

user1555112
user1555112

Reputation: 1977

I think I found the right way: As I am sending with jquery a post to the controller I need to send the value back as json:

$this->response->body(json_encode(array('iban' => $result->validateIban)));
return $this->response;

Upvotes: 1

Related Questions