I have installed this package.
My mock data class:
import { InMemoryDbService } from 'angular-in-memory-web-api';
export class InCredentialsService implements InMemoryDbService {
public createDb() {
const credentials = {
auth: true,
id: 1,
token: 'token',
grant: 'all'
};
return credentials;
}
}
In app.module.ts
I set dependence in import
section:
InMemoryWebApiModule.forRoot(InMemoryDataService)
Now I try to use that like this:
return this.http.get('api/credentials');
It returns me HTTP error:
Response with status: 404 Not Found for URL: api/credentials
How to use angular-in-memory-web-api right?
Use
return { credentials };
This is the short form for
return { credentials: credentials };
and the identifier becomes the API.