8000 docs: example of `resetDb` command with option in the request. · angular/in-memory-web-api@dea9a2d · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit dea9a2d

Browse files
committed
docs: example of resetDb command with option in the request.
1 parent fcb2afd commit dea9a2d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,26 @@ They ignore the latency delay and respond as quickly as possible.
304304

305305
The `resetDb` command
306306
calls your `InMemoryDbService` data service's [`createDb` method](#createDb) with the `RequestInfo` object,
307-
enabling the `createDb` logic to adjust its behavior per the client request. See the tests for examples.
307+
enabling the `createDb` logic to adjust its behavior per the client request.
308+
309+
In the following example, the client includes a reset option in the command request body:
310+
```
311+
http
312+
// Reset the database collections with the `clear` option
313+
.post('commands/resetDb', { clear: true }))
314+
315+
// when command finishes, get heroes
316+
.concatMap(
317+
()=> http.get<Data>('api/heroes')
318+
.map(data => data.data as Hero[])
319+
)
320+
321+
// execute the request sequence and
322+
// do something with the heroes
323+
.subscribe(...)
324+
```
325+
326+
See the tests for other examples.
308327

309328
## _parseRequestUrl_
310329

0 commit comments

Comments
 (0)
0