I’m using json-server as a fake api, and when making the POST request, my ids are not being generated automatically, note that they are already as a String, which is as recommended in the documentation.
My class user
export class User {
public id: String = ''
public name: String = ''
public phone: String = ''
public email: String = ''
public cpf: String = ''
public password: String = ''
}
from 10 to 13 I manually put the data in my db.json, after that we can notice that the id is not coming automatically
{
"id": "10",
"firstName": "Bruno",
"email": "[email protected]",
"phone": "323",
"cpf": "05126769685",
"password": "fdsfds"
},
{
"id": "11",
"firstName": "Bruno",
"email": "[email protected]",
"phone": "323",
"cpf": "05126769685",
"password": "fdsfds"
},
{
"id": "12",
"firstName": "Bruno",
"email": "[email protected]",
"phone": "323",
"cpf": "05126769685",
"password": "fdsfds"
},
{
"id": "13",
"firstName": "Bruno",
"email": "[email protected]",
"phone": "323",
"cpf": "05126769685",
"password": "fdsfds"
},
{
"id": "",
"name": "teste",
"phone": "1111111111",
"email": "[email protected]",
"cpf": "18361591885",
"password": "111"
}
]
on the npm website it says id is always a string and will be generated for you if missing
json-server npm