Ad

Path With '/' In Json-server Db.json

- 1 answer

i use server-json to have a fake API, i have the path "playbook/active" in data.json

"playbook/active": [{
    "description": "This playbook will install haproxy",
    "name": "Testing playbook 3",
    "tag": [
      "loadbalancer",
      "charge"
    ],
    "path": "/etc/ansible/haproxy.yml",
    "type": "action",
    "id": "4bb107be-9efe-11e9-b3e5-bc5ff4901aa5"
  },
  {
    "path": "google.com",
    "description": "This is the playbook before execution",
    "tag": [
      "webserver",
      "tomcat"
    ],
    "id": "faa746b4-9cb7-11e9-9b94-bc5ff4901aa5",
    "name": "mysql"
  }
]

but i have this error

Error: Oops, found / character in database property 'playbook/active'.

I change to "playbook/active" but same error

Ad

Answer

Check the error message:

Oops, found / character in database property 'dossier/la'.

/ aren't supported, if you want to tweak default routes, see
https://github.com/typicode/json-server/#add-custom-routes

It seems that slashes are not supported.

The solution is to create a routes.json file containing the mapping for your url.

For example the contents of this file could be:

{
  my-awesome-endpoint": "playbook/active"
}
Ad
source: stackoverflow.com
Ad