2
我已經安裝了這個包。如何使用角度,內存,網絡API中Angular2?
我的模擬數據類:
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;
}
}
在app.module.ts
我設置的依賴在import
部分:
InMemoryWebApiModule.forRoot(InMemoryDataService)
現在我嘗試使用這樣的:
return this.http.get('api/credentials');
它返回我的HTTP錯誤:
Response with status: 404 Not Found for URL: api/credentials
如何使用角度,內存,網絡API嗎?