Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple-crud writes data but does not show it #95

Open
xbln opened this issue Jul 14, 2020 · 3 comments
Open

simple-crud writes data but does not show it #95

xbln opened this issue Jul 14, 2020 · 3 comments

Comments

@xbln
Copy link

xbln commented Jul 14, 2020

For testing purposes I created a json-file db.json with no data like this:
{ "tasks": [ { } ] }

I also created a file routes.json
{ "/api/demo/tasks": "/tasks" }

I than started a json api server with json-server db.json on default port 3000

I changed 'url:' in api.js to url: 'http://127.0.0.1:3000' and ran vue-crud (simple-crud) by npn run serve
The vue-crud page displays with no errors. I add a record with the + symbol, the json-server accepts it with 201 and POST /api/demo/tasks 201 27.237 ms - 92. The db.json file got the record as expected:
{ "tasks": [ { "name": "test", "description": "this is a test record", "apiId": "demo", "id": 1 } ] }

The problem is, that vue-crud does not show this (or any) record. Refreshing does not help, the list stays beeing empty.

@zhuzhouliang
Copy link

Hi, I ran into the same problem like yours. It turns out to be the problem of my model definition. The task should have one important attribute: active, which should be int type and has default value 1. Otherwise no record will be shown.

@xbln
Copy link
Author

xbln commented Jul 31, 2020

Thanks, zhuzhouliang! I´ll try this. However, active should be defaulted to 1.

@Polarbear08
Copy link

Hi, I encountered the same problem and now I got the 'active' attribute should be 1.
However, It's still unclear where I should fix to make active field 1 by default.

I put a record like below into db.json

{
  "tasks": [
    {
      "name": "test",
      "description": "Yeah!\n",
      "id": 1,
      "active": 1
    }
  ]
}

routes.js

{
    "/demo/tasks": "/tasks",
    "/demo/tasks/:id": "/tasks/:id"
}

And started json server

yarn run json-server --watch db.json --routes routes.json

Although the data was shown at first, It disappeared after I modified the id:1 record on the browser.
The data after the edit was like:

{
  "tasks": [
    {
      "name": "test",
      "description": "edited",
      "id": 1
    }
  ]
}

How to avoid this and set 1 into active filed?

I appreciate your kindness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants