Angular 2 Angular2 In Memory Web API Setting Up Multiple Test API Routes


Example

mock-data.ts

export class MockData {
    createDb() {
        let mock = [
            { id: '1', name: 'Object A' },
            { id: '2', name: 'Object B' },
            { id: '3', name: 'Object C' }
        ];
        
        let data = [
            { id: '1', name: 'Data A' },
            { id: '2', name: 'Data B' },
            { id: '3', name: 'Data C' }
        ];

        return { mock, data };
    }
}

Now, you can interact with both

app/mock
and
app/data
to extract their corresponding data.