export class MockedDataService {
constructor(private Session: SessionService) {}
private getMocked(name:string){
return ""; // return whatever result is, will be a promise
}
public mocked:{
products:{
getAllProducts: function(){return this.getMocked("")},
getProductByType: function(type){return this.getMocked(type)}
}
}
}
Now if this class is injected in a component, then you can call this service as
this.MockedDataService.mocked.products.getAllProducts().then((result) => {
console.log(result);
}).catch((err) => {
console.log("error: ",err.message);
});
Then an error is raised: "this.getMocked is not a function" a fix for that issue is to change the code to :
getAllProducts: function(){return ()=> this.getMocked("")}
But this fix will raise another error: "this.MockedDataService.mocked.products.getAllProducts().then is not a function"