LoginSignup
0

More than 3 years have passed since last update.

axios

Posted at
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>

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0