Open arturhun opened 5 years ago
By looking into interfaces.d.ts I managed to come up with something like:
delete(reqInfo: RequestInfo) {
reqInfo.utils.createResponse$(() => {
return of({
collection: collection.filter(item => !deleteSet.has(item.id)),
});
});
}
Functionally, this seems to work, however:
.utils
type which allegedly doesn't exist on type RequestInfo, it doesn't exist on type string.We have type RequestInfo = Request | string;
but (reqInfo as Request).utils.
still leaves the squiggles underneath utils
.
The above shows that the docs leave much of guesswork for a developer and it could be avoided by provided a decent example.
did you check under this directory for examples? https://github.com/angular/in-memory-web-api/tree/master/src/app
OK, the typing problem came from that I didn't have an explicit import from the library and so TypeScript used RequestInfo
from lib.dom.d.ts
@vishal423 Yes I did. and the code that I used based on that
return of({
items: collection.filter(item => !deleteSet.has(item.id)), // my collection is `items`
});
didn't work.
Please provide a simple example of constructing a valid response in a method interceptor.
The ticket #44 refers to something that apparently has been moved, and the example in the README is very general, succinct and I find it not helpful at all.