axios
<html>
<head>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<script>
const request = axios.create({
/**
無料のAPIサービスにデータ登録し発行されたエンドポイント
データが消えている場合は
https://jsonstorage.netで以下のデータを登録しエンドポイントを再取得する。
[
{ "name": "山田", "age": 20, "genderId": 0, "skillIds": [0, 1, 2] },
{ "name": "吉田", "age": 30, "genderId": 1, "skillIds": [0, 1, 2, 3] },
{ "name": "佐藤", "age": 40, "genderId": 0, "skillIds": [0] }
]
*/
baseURL: 'https://jsonstorage.net/api/items/a8e80302-1cfd-49be-aca6-095e68da8a2f'
});
request.get().then(res => {
const gender = {0: '男', 1: '女'};
for (const user of res.data) {
console.log(user.name);
console.log(gender[user.genderId]);
}
});
</script>
</body>
</html>