Skip to content

Commit c7febf2

Browse files
committed
add why-ts code
1 parent 7d559da commit c7febf2

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

why-ts/app.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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();

why-ts/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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>

0 commit comments

Comments
 (0)