POST create data should not send index
youwillbe opened this issue · comments
When I want to create a data like "user", I'd like to make a request like this:
fetch('rooturl/users', {
method: 'POST',
body: { username: 'xxxx', passwd: '*****' }
})
instead of:
fetch('rooturl/users/1', {
method: 'POST',
body: { username: 'xxxx', passwd: '*****' }
})
then you assign an id
to this data.
Now the data structure should look like this:
{
users: [
{ id: 0, username: 'xxxx', passwd: '*****' }
]
}
then I can get all users:
fetch('rooturl/users', {
method: 'GET'
})
and get one of them:
// id = 0
fetch('rooturl/users/${id}', {
method: 'GET'
})
update it:
// id = 0
fetch('rooturl/users/${id}', {
method: 'PUT',
body: { username: 'xxx', passwd: '******' }
})
or
// id = 0
fetch('rooturl/users', {
method: 'PUT',
body: { id: id, username: 'xxx', passwd: '******' }
})
and delete it:
// id = 0
fetch('rooturl/users/${id}', {
method: 'DELETE'
})
Do you think so?
In addition, why don't you open the dashboard?
I don't think that is really what this project is about. It does not have any logic in it's backend. To make something like this work the server would need to be aware of data structure. It is not aware of that. Use something like firebase instead or implement this in a custom backend.