Skip to content

Instantly share code, notes, and snippets.

@johnny12150
Created July 9, 2021 19:45
Show Gist options
  • Save johnny12150/c27c1f81a297ea9bc578a7f96bf801ba to your computer and use it in GitHub Desktop.
Save johnny12150/c27c1f81a297ea9bc578a7f96bf801ba to your computer and use it in GitHub Desktop.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Load CDC API</title>
</head>
<body>
</body>
<script>
// https://ithelp.ithome.com.tw/articles/10244631
// https://data.gov.tw/dataset/120711
// const dataset_url = 'https://od.cdc.gov.tw/eic/Day_Confirmation_Age_County_Gender_19CoV.json';
// 用proxy避免CORS, https://github.com/Rob--W/cors-anywhere/
// const dataset_url_cors = 'https://cors-anywhere.herokuapp.com/https://od.cdc.gov.tw/eic/Day_Confirmation_Age_County_Gender_19CoV.json';
function get_data(){
fetch('https://raw.githubusercontent.com/typicode/demo/master/db.json')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(myJson);
});
}
get_data()
</script>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Load CDC API</title>
</head>
<body>
</body>
<script>
// https://ithelp.ithome.com.tw/articles/10244631
// https://data.gov.tw/dataset/120711
// const dataset_url = 'https://od.cdc.gov.tw/eic/Day_Confirmation_Age_County_Gender_19CoV.json';
// 用proxy避免CORS, https://github.com/Rob--W/cors-anywhere/
// const dataset_url_cors = 'https://cors-anywhere.herokuapp.com/https://od.cdc.gov.tw/eic/Day_Confirmation_Age_County_Gender_19CoV.json';
function get_data(){
fetch('https://raw.githubusercontent.com/typicode/demo/master/db.json')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
console.log(myJson);
});
}
get_data()
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment