Skip to content

Commit

Permalink
Init json-server
Browse files Browse the repository at this point in the history
  • Loading branch information
Han Thuy Vi committed Jun 20, 2022
1 parent a641264 commit a06482f
Show file tree
Hide file tree
Showing 378 changed files with 3,240 additions and 13,938 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json-server/node_modules
25 changes: 25 additions & 0 deletions json-server/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var coursesApi = 'http://localhost:3000/courses'

function start() {
getCouresApi(renderCode)

};
start()

function getCouresApi(callback) {
fetch(coursesApi)
.then(function (respones) {
return respones.json();
})
.then(callback)
};

function renderCode(courses) {
var coursesblock = document.querySelector('#test')
var html = courses.map(function (course) {
return `
<li>${course.name}
`
});
coursesblock.innerHTML = html.join('')
}
19 changes: 19 additions & 0 deletions json-server/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"courses": [
{
"id": 1,
"name": "JSON server",
"descripttion": "Tham gia nhóm Học lập trình tại F8 trên Facebook để cùng nhau trao đổi trong quá trình học tập ❤️"
},
{
"name": "HTML, CSS từ Zero đến Hero",
"description": "Trong khóa này chúng ta sẽ cùng nhau xây dựng giao diện 2 trang web là The Band & Shopee.",
"id": 2
},
{
"name": "Comments trong HTML",
"description": "Để có cái nhìn tổng quan về ngành IT - Lập trình web các bạn nên xem các videos tại khóa này trước nhé.",
"id": 3
}
]
}
6 changes: 2 additions & 4 deletions lesson1/index.html → json-server/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./app.css">
</head>
<body>
<h1>Lesson 1 - start</h1>
<div id="result"></div>

<ul id="test"></ul>

<script src="./app.js"></script>
</body>
</html>
Loading

0 comments on commit a06482f

Please sign in to comment.