File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ // api url
2
+ var url = 'https://jsonplaceholder.typicode.com/users/1' ;
3
+
4
+ // dom
5
+ var username = document . querySelector ( '#username' ) ;
6
+ var email = document . querySelector ( '#email' ) ;
7
+ var address = document . querySelector ( '#address' ) ;
8
+
9
+ // user data
10
+ var user = { } ;
11
+
12
+ function startApp ( ) {
13
+ axios
14
+ . get ( url )
15
+ . then ( function ( response ) {
16
+ console . log ( response ) ;
17
+ user = response . data ;
18
+ // TODO: 이름, 이메일, 주소 표시하기
19
+ } )
20
+ . catch ( function ( error ) {
21
+ console . log ( error ) ;
22
+ } ) ;
23
+ }
24
+
25
+ startApp ( ) ;
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
+ < title > Why Typescript?</ title >
7
+ </ head >
8
+ < body >
9
+ < h1 > 사용자 정보</ h1 >
10
+ < div >
11
+ < p > 이름: < span id ="username "> </ span > </ p >
12
+ < p > 이메일: < span id ="email "> </ span > </ p >
13
+ < p > 주소: < span id ="address "> </ span > </ p >
14
+ </ div >
15
+
16
+ < script src ="https://unpkg.com/axios/dist/axios.min.js "> </ script >
17
+ < script src ="./app.js "> </ script >
18
+ </ body >
19
+ </ html >
You can’t perform that action at this time.
0 commit comments