Closed Stephane-Peyroutet closed 6 years ago
This works for me with no issues:
import { InMemoryDbService } from 'angular-in-memory-web-api';
export class InMemHeroService implements InMemoryDbService {
createDb() {
let heroes = [
{ id: 1, name: 'Windstorm' },
{ id: 2, name: 'Bombasto' }
];
return {
'heroes-with-hyphens': heroes
};
}
}
There is no restriction on collection names, you can name them however you like, just use the 'key' : value notation.
Okay, good one, I completely forgot I could use the 'key': value notation in the return statement. Thanks @LambdaCruiser .
For my REST API calls, I wish to use the widely convention of using URL names with only letters, digits and hypens (eg : customers, purchase-orders, sale-orders, ...). But the InMemoryDbService use collection names that must be valid TS/JS names so I can't directly use hyphens in them. I've read that I can implement a custom "parseRequestUrl" method in my InMemoryDbService but I didn't found any examples on the web for my simple use case. Is this feasible ? Can aynone point me in the right direction or provide a sample code ?