Monday, 25 March 2019

How to In memory web api for two different jsons

I am using In memory web api for two json services(DB)

1)

import {InMemoryDbService} from 'angular-in-memory-web-api';
export class InMemoryDataService implements InMemoryDbService {
    createDb() {
        let heroes = [
            {id: 11, name: 'Mr. Nice'},
            {id: 12, name: 'Narco'},
            {id: 13, name: 'Bombasto'},
            {id: 14, name: 'Celeritas'},
            {id: 15, name: 'Magneta'},
            {id: 16, name: 'RubberMan'},
            {id: 17, name: 'Dynama'},
            {id: 18, name: 'Dr IQ'},
            {id: 19, name: 'Magma'},
            {id: 20, name: 'Tornado'}
        ];
        return {heroes};
    }
}      

2)

import {InMemoryDbService} from 'angular-in-memory-web-api';

import {Address} from "cluster";

export class StudentData implements InMemoryDbService {
    createDb() {

        let students = [
            {
                id: 11,
                FirstName: 'Mounika',
                LastName: 'Gangamwar',
                email: 'asa@gmailc.com',
                Phonenumber: 1111,
                Address: '2323',
                Password: 'asa',
                CPassword: 'aa'
            }
        ];
        return {students};
    }
}

My app.module.js is

import {InMemoryWebApiModule} from 'angular-in-memory-web-api';

import {InMemoryDataService}  from './in-memory-data.service';

import {StudentData} from './forms/student.data.service';

@
NgModule({
    imports: [
        BrowserModule,
        FormsModule,
        InMemoryWebApiModule.forRoot(InMemoryDataService, StudentData)
    ],
    declarations: [AppComponent],
    bootstrap: [UIView]
})

My problem is I'm not able to add two db in InMemoryWebApiModule.forRoot(InMemoryDataService,StudentData)]

I am getting 404 error for StudentData service. If I remove one dbService from it's working fine

My doubt is how to add two dbservices to forRoot method?



from How to In memory web api for two different jsons

No comments:

Post a Comment