# |
Feb 9th 2020, 11:30 |
damiano |
no works @challgren |
# |
Feb 9th 2020, 11:30 |
challgren |
This |
# |
Feb 9th 2020, 11:29 |
damiano |
Notice Error: Undefined variable: routes |
# |
Feb 9th 2020, 11:29 |
challgren |
your anonymouse callback with RouteBuilder is named something different than the books docs |
# |
Feb 9th 2020, 11:29 |
damiano |
ops |
# |
Feb 9th 2020, 11:29 |
damiano |
no wait if i put inside the scope i get $routes->setExtensions(['json']); |
# |
Feb 9th 2020, 11:28 |
damiano |
ok |
# |
Feb 9th 2020, 11:28 |
damiano |
inside |
# |
Feb 9th 2020, 11:28 |
damiano |
pl |
# |
Feb 9th 2020, 11:28 |
challgren |
Put it inside |
# |
Feb 9th 2020, 11:28 |
damiano |
it is outside the scope |
# |
Feb 9th 2020, 11:28 |
challgren |
otherwise it wont attach the routes above |
# |
Feb 9th 2020, 11:28 |
damiano |
@challgren ^ his is my routes.php |
# |
Feb 9th 2020, 11:28 |
challgren |
first line |
# |
Feb 9th 2020, 11:27 |
challgren |
`$builder->setExtensions(['json']);` |
# |
Feb 9th 2020, 11:27 |
challgren |
no inside your scope |
# |
Feb 9th 2020, 11:27 |
slackebot |
'payment']);` `$builder->fallbacks();` `});` |
# |
Feb 9th 2020, 11:27 |
damiano |
`$routes->setRouteClass(DashedRoute::class);` `$routes->setExtensions(['json']);` `$routes->scope('/', function (RouteBuilder $builder) {` `$builder->connect('/*', ['controller' => 'Pages',], ['_name' => 'home']);` `$builder->connect('/prenota/*', ['controller' => 'Pages', 'action' => 'prenota'], ['_name' => 'book']);` `$builder->connect('/pagamento', ['controller' => 'Pages', 'action' => 'pagamento'], ['_name' => |
# |
Feb 9th 2020, 11:25 |
challgren |
`$routes->setExtensions(['json']);` |
# |
Feb 9th 2020, 11:25 |
challgren |
Do this instead https://book.cakephp.org/4/en/development/routing.html#file-extensions |
# |
Feb 9th 2020, 11:24 |
damiano |
hmm |
# |
Feb 9th 2020, 11:24 |
damiano |
/pagamento.json |
# |
Feb 9th 2020, 11:24 |
challgren |
no |
# |
Feb 9th 2020, 11:24 |
damiano |
should i add .json over there too ? |
# |
Feb 9th 2020, 11:24 |
damiano |
$builder->connect('/pagamento', ['controller' => 'Pages', 'action' => 'pagamento'], ['_name' => 'payment']); |
# |
Feb 9th 2020, 11:24 |
damiano |
i have |
# |
Feb 9th 2020, 11:24 |
damiano |
@challgren hmm i see the home page... maybe a route problem |
# |
Feb 9th 2020, 11:22 |
damiano |
one moment |
# |
Feb 9th 2020, 11:22 |
damiano |
oh i miss the extension...maybe it's the problem |
# |
Feb 9th 2020, 11:21 |
challgren |
try .json if that doesnt work request with content-type application/json |
# |
Feb 9th 2020, 11:21 |
challgren |
Also is request handler loaded?> |
# |
Feb 9th 2020, 11:20 |
challgren |
try `$this->viewBuilder()->setOption('serialize', ['articles']);` |
# |
Feb 9th 2020, 11:20 |
damiano |
(note: i do not need a json view, i can work with the default one) |
# |
Feb 9th 2020, 11:20 |
damiano |
there is no json response |
# |
Feb 9th 2020, 11:20 |
damiano |
i do not see any output from the server |
# |
Feb 9th 2020, 11:20 |
damiano |
what should i have to return to see the json? |
# |
Feb 9th 2020, 11:20 |
damiano |
``` // Set the view vars that have to be serialized. $this->set('articles', $this->paginate()); // Specify which view vars JsonView should serialize. $this->viewBuilder()->setOption('serialize', 'articles');``` |
# |
Feb 9th 2020, 11:19 |
damiano |
https://book.cakephp.org/4/en/views/json-and-xml-views.html#using-data-views-with-the-serialize-key |
# |
Feb 9th 2020, 11:19 |
damiano |
i need a json response |
# |
Feb 9th 2020, 11:19 |
damiano |
hello everybody, |
# |
Feb 9th 2020, 09:44 |
slackebot |
<challgren> |