Dingo api $response is undefined

221 Views Asked by At

Getting error

"message": "Undefined property: App\Http\Controllers\Api\ApiUserXYzController::$response"

return $this->response->collection($user_list, new ProjectTransformer())->setStatusCode(200);

I"m tring to transform the data but i'm getting $response is not defined. please guide

1

There are 1 best solutions below

0
On BEST ANSWER

You forgot to include the helper trait that the docs tell you to use if you want the response builder at the property response on the controller.

Dingo Wiki - Responses - Response Builder

use Dingo\Api\Routing\Helpers;

class SomeController ....
{
    use Helpers;
    ...
}