How do we create multiple collections using Angular-in-memory-web-api? Not an issue with single collection. But I\'m not able to implement it f
Just return it an object with both arrays. In the example from Angular, you see something like
createDb() {
let heroes = [ .. ]
return { heroes }
}
If you don't already know this, { heroes }
is just shorthand for writing { heroes: heroes }
. So if you have two collections, then just add it as a another property
createDb() {
let heroes = [ .. ];
let crises = [ .. ];
return { heroes, crises };
// or { heroes: heroes, crises: crises }
}
The name of the property returned will be used for the path in the URL. So you can use
/api/heroes/1
/api/crises/1