-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathrickmorty.js
39 lines (28 loc) · 948 Bytes
/
rickmorty.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Exercise
Let's create a utility function to retrieve all the Rick and Morty characters!
Yes, there's an API for that. Check out https://rickandmortyapi.com/
We want to implement a `createCharactersPaginator` factory function that returns
an iterator of pages. Every page contains multiple characters.
You can get the first page by calling:
```
GET https://rickandmortyapi.com/api/character
```
The iterator should emit values that look like this:
```json
[
"character1",
"character2",
"character3",
...
"character20"
]
```
An array with a maximum of 20 character names.
You can use `axios`, `node-fetch` or `undici`, they are all already available in your `node_modules`!
Run the tests with:
npm run ex -- 05-async-iterator-protocol/exercises/rickmorty.test.js
*/
export default function createCharactersPaginator () {
// return an iterator that returns pages of characters
}