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

报错item['id'] = randomId();TypeError: Cannot create property 'id' on string 'a' #1501

Closed
liangyuhong160 opened this issue Jan 26, 2024 · 2 comments

Comments

@liangyuhong160
Copy link

定义字符串数组,如:
{
"list": ["a", "b", "c"]
}
执行json-server --watch的时候报错:
item['id'] = randomId();TypeError: Cannot create property 'id' on string 'a'
版本:1.0.0 -alpha.22

@typicode
Copy link
Owner

list must contain an array of objects

Something like [{ "value": "a" }, { "value": "b" }, ...]

@mhimlinhm
Copy link

I know this issue is closed, but I was able to work around this. With the json-server already running, if I update my db.json file with an array of strings as shown above and save, it refreshes and adds the endpoint just fine. However if you stop json-server and try to start with that modified db.json, you get the error mentioned.

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