Open Fanchao92 opened 6 years ago
Hello, you can add a genId method to your service to handle the ids, someting like that :
genId<T extends { id: any }>(collection: T[], collectionName: string): any {
return collection.reduce((prev, curr) =>
{
return (curr.id + 1) || 0;
}, 1);
}
In my dev environment, I use InMemoryDbService to emulate a back-end database. Now I am trying to create a new row in my DB when the DB is empty. I send a post request with my new object, except that the object does NOT have an id and I am assuming the server will auto-create it for me. However, the post request fails due to 'id type is non-numeric or unknown. Can only generate numeric ids.'