File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7+ < title > Document</ title >
8+ </ head >
9+ < body >
10+
11+
12+ < script >
13+
14+ async function obtenerClientes ( ) {
15+ const clientes = new Promise ( ( resolve , reject ) => {
16+ setTimeout ( ( ) => {
17+ resolve ( `Clientes descargados...` ) ;
18+ } , 2000 ) ;
19+ } ) ;
20+
21+ const error = false ;
22+
23+ if ( ! error ) {
24+ const respuesta = await clientes ;
25+ return respuesta ;
26+ } else {
27+ await Promise . reject ( `Hubo un error...` ) ;
28+ }
29+ }
30+
31+ obtenerClientes ( )
32+ . then ( res => console . log ( res ) )
33+ . catch ( error => console . log ( error ) ) ;
34+
35+ </ script >
36+ </ body >
37+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7+ < title > Document</ title >
8+ </ head >
9+ < body >
10+
11+ < script >
12+ async function leerTodos ( ) {
13+ const respuesta = await fetch ( 'https://jsonplaceholder.typicode.com/todos' ) ;
14+
15+ const datos = await respuesta . json ( ) ;
16+
17+ return datos ;
18+ }
19+
20+ //console.log(leerTodos());
21+
22+ leerTodos ( )
23+ . then ( usuarios => console . log ( usuarios ) ) ;
24+ </ script >
25+ </ body >
26+ </ html >
You can’t perform that action at this time.
0 commit comments