My goal is to use in-memory-web-api interchangeably with a real backend.
As stated in the Angular 2 (or 4) Tour of Heroes tutorial https://angular.io/tutorial/toh-pt6#extracting-the-data-in-the-then-callback :
Note the shape of the data that the server returns. This particular in-memory web API example returns an object with a data property. Your API might return something else. Adjust the code to match your web API.
The mocked web api service returns an object wrapped in a data attribute. The problem is that my backend doesn't return the data in that format, it doesn't have a "data" attribute.
.then(response => response.json().data as Hero[])
should be
.then(response => response.json() as Hero[])
and hopefully it should work. If I change it to the second version, the in-memory api doesn't work anymore...
Is there a way that I can change in-memory-web-api to actually remove that data attribute?