├── inyeccion
├── index.html
└── main.js
├── iterator
└── index.html
├── observador
└── index.html
└── prototype
└── index.html
/inyeccion/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Title
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/inyeccion/main.js:
--------------------------------------------------------------------------------
1 | class News{
2 | constructor(url, parameter){
3 | this.url = url + "/" + parameter;
4 | }
5 |
6 | async get(){
7 | let posts = await fetch(this.url)
8 | .then(response => response.json())
9 | .then(json => json);
10 | return posts;
11 | }
12 | }
13 |
14 | class Writer{
15 |
16 | constructor(news){
17 | this.news = news;
18 | }
19 |
20 | async show(){
21 | this.posts = await this.news.get();
22 | console.log(this.posts.title);
23 | /*this.posts.forEach(element => {
24 | console.log(element.title);
25 | });*/
26 | }
27 | }
28 |
29 | let news = new News("https://jsonplaceholder.typicode.com/todos/",2);
30 | let writer = new Writer(news);
31 | writer.show();
--------------------------------------------------------------------------------
/iterator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Title
7 |
8 |
9 |
10 |
11 |
12 |
13 |
59 |
60 |
--------------------------------------------------------------------------------
/observador/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Title
7 |
8 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
46 |
115 |
--------------------------------------------------------------------------------
/prototype/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Page Title
7 |
8 |
9 |
10 |
11 |
12 |
13 |
70 |
--------------------------------------------------------------------------------