質問編集履歴

2

コードの変更

2020/11/06 06:26

投稿

maskmelon
maskmelon

スコア63

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,21 @@
4
4
 
5
5
 
6
6
 
7
+ ※コード修正しました
8
+
7
9
  ```js
10
+
11
+ export const fetchBookByIsbn = async isbnInput => {
12
+
13
+ const url = `https://app.rakuten.co.jp/services/api/BooksBook/Search/20170404?applicationId=${rakutenAppId}&isbn=${isbnInput}`;
14
+
15
+
16
+
17
+ const response = await fetch(url);
18
+
19
+ const data = await response.json();
20
+
21
+ const bookData = data.Items.map(val => val.Item)[0];
8
22
 
9
23
  const {
10
24
 
@@ -24,4 +38,8 @@
24
38
 
25
39
  return book;
26
40
 
41
+ };
42
+
43
+
44
+
27
45
  ```

1

追記

2020/11/06 06:26

投稿

maskmelon
maskmelon

スコア63

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- APIから取得したデータを整形して返すコードなのですが、繰り返しが多く冗長な感じがします。
1
+ APIから取得したデータを整形して返すコードなのですが、繰り返しが多く冗長な感じがします。
2
2
 
3
3
  一度に変数`book`の中に必要なデータを入れることはできないでしょうか?
4
4