Got around it. I found this GitHub file on the angular-in-memory-web-api docs: https://github.com/angular/in-memory-web-api/blob/master/src/app/hero-in-mem-data-override.service.ts and constructed the following solution:
import { getStatusText, STATUS } from 'angular-in-memory-web-api/http-status-codes';
import { InMemoryDbService, RequestInfo } from 'angular-in-memory-web-api';
get(reqInfo: RequestInfo) {
// Extract ids from URL
const ids: Array<number> = reqInfo.req.urlWithParams.match(/[0-9]+/g).map(n => +(n));
// If there's more than one ID in the URL then we call the appropriate function
if (ids.length > 1) {
return this.getRelationshipDetails(reqInfo, ids)
}
}
private getRelationshipDetails(reqInfo: RequestInfo, ids: Array<number>) {
console.log('HTTP GET override')
const entities = reqInfo.collection;
return reqInfo.utils.createResponse$(() => {
const data = entities.filter(entity => ids.indexOf(entity.id) !== -1)
const dataEncapsulation = reqInfo.utils.getConfig().dataEncapsulation;
const options: any = data ?
{
body: dataEncapsulation ? { data } : data,
status: STATUS.OK
} :
{
body: { error: `Entities with ids='${ids}' not found` },
status: STATUS.NOT_FOUND
};
return this.finishOptions(options, reqInfo)
});
}
private finishOptions(options: any, { headers, url }: RequestInfo) {
options.statusText = getStatusText(options.status);
options.headers = headers;
options.url = url;
return options;
}