teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

scriptを追記しました

2020/09/18 15:31

投稿

tktail
tktail

スコア72

title CHANGED
File without changes
body CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  まず下記のようなJSONデータがあります。
4
4
  ```
5
- {"id":"000001","createdAt":"2020-09-01","updatedAt":"2020-09-01","publishedAt":"2020-09-01","title":"Hello World","content":"First Contents","image":{"url":"https://test.jpg"},"category":["cate01"]
5
+ {"id":"000001","createdAt":"2020-09-01","updatedAt":"2020-09-01","publishedAt":"2020-09-01","title":"Hello World","content":"First Contents","image":{"url":"https://test.jpg"},"category":["cate01"]}
6
6
  ```
7
7
 
8
8
  nuxt.jsでaxiosを使用し
@@ -12,4 +12,17 @@
12
12
  <img src="###">
13
13
  この###の部分に{ iamge }としても動きません。(当然かと思いますが・・・)
14
14
 
15
+ ちなみにscriptは以下のようになっています。
16
+ ```
17
+ async asyncData() {
18
+ const { data } = await axios.get(
19
+ 'https://sample.com',
20
+ {
21
+ headers: { 'X-API-KEY': '###' }
22
+ }
23
+ )
24
+ return data
25
+ }
26
+ ```
27
+
15
28
  解決方法をご存じの方、いらっしゃいましたらよろしくお願い致します。