Hi
In my project I use backbone.js + marionette and Yii2
But I have some problem with REST api.
I have separated module named “shop” with main page (it’s a simple page for bootstrap all needed scripts and other data)
account.local/shop
in this module i also want use REST api for loading data for models and collection
part of my config
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'products'],
],
],
'request' => [
'class' => 'yii\web\Request',
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
],
When I’m getting collection
curl -i -H ‘Accept:application/json’ -X GET ‘account.local/shop/products’
It’s ok
[{"id":16,"name":"product1"},{"id":17,"name":"product2"},{"id":18,"name":"product3"},{"id":19,"name":"product4"},{"id":20,"name":"product5"},{"id":21,"name":"product6"}]
But when I try get single model - 404!!!
curl -i -H ‘Accept:application/json’ -X GET ‘account.local/shop/products/16’
Maybe I do something wrong???