質問編集履歴
4
***に変換
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,9 +118,9 @@
|
|
118
118
|
|
119
119
|
async asyncData ({ $axios }) {
|
120
120
|
|
121
|
-
const data = await $axios.$get('
|
121
|
+
const data = await $axios.$get('------------------------------------', {
|
122
|
-
|
122
|
+
|
123
|
-
headers: { 'X-API-KEY': '
|
123
|
+
headers: { 'X-API-KEY': '-----------------------------------' }
|
124
124
|
|
125
125
|
})
|
126
126
|
|
3
解決
test
CHANGED
File without changes
|
test
CHANGED
@@ -281,3 +281,75 @@
|
|
281
281
|
</script>
|
282
282
|
|
283
283
|
```
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
### 解決
|
290
|
+
|
291
|
+
```
|
292
|
+
|
293
|
+
<template lang="pug">
|
294
|
+
|
295
|
+
div
|
296
|
+
|
297
|
+
.items
|
298
|
+
|
299
|
+
.item-box(v-for='item in items' :key='item.id')
|
300
|
+
|
301
|
+
.name
|
302
|
+
|
303
|
+
| {{ item.title }}
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
</template>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
<script>
|
312
|
+
|
313
|
+
export default {
|
314
|
+
|
315
|
+
data () {
|
316
|
+
|
317
|
+
return {
|
318
|
+
|
319
|
+
items: ''
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
},
|
324
|
+
|
325
|
+
mounted() {
|
326
|
+
|
327
|
+
this.asyncData()
|
328
|
+
|
329
|
+
},
|
330
|
+
|
331
|
+
asyncData () {
|
332
|
+
|
333
|
+
await axios.get('https://*******.microcms.io/api/v1/news',{
|
334
|
+
|
335
|
+
headers: { 'X-API-KEY': '****************************' }
|
336
|
+
|
337
|
+
})
|
338
|
+
|
339
|
+
.then(res =>{
|
340
|
+
|
341
|
+
console.log(res)
|
342
|
+
|
343
|
+
this.items= res.data.contents
|
344
|
+
|
345
|
+
})
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
</script>
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
```
|
2
***に変換
test
CHANGED
File without changes
|
test
CHANGED
@@ -260,9 +260,9 @@
|
|
260
260
|
|
261
261
|
async asyncData ({ $axios }) {
|
262
262
|
|
263
|
-
const data = await $axios.$get('https://
|
263
|
+
const data = await $axios.$get('https://*******.microcms.io/api/v1/news', {
|
264
|
-
|
264
|
+
|
265
|
-
headers: { 'X-API-KEY': '
|
265
|
+
headers: { 'X-API-KEY': '****************************' }
|
266
266
|
|
267
267
|
})
|
268
268
|
|
1
Section04.vueのコードです。
test
CHANGED
File without changes
|
test
CHANGED
@@ -217,3 +217,67 @@
|
|
217
217
|
コンポーネント化するとどうして何も出力されないのでしょうか?
|
218
218
|
|
219
219
|
なにか別の設定があるのでしょうか?
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
**※追記Section04.vueです。**
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
```Section04.vue
|
228
|
+
|
229
|
+
<template lang="pug">
|
230
|
+
|
231
|
+
div
|
232
|
+
|
233
|
+
.items
|
234
|
+
|
235
|
+
.item-box(v-for='item in items' :key='item.id')
|
236
|
+
|
237
|
+
.name
|
238
|
+
|
239
|
+
| {{ item.title }}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
</template>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<script>
|
248
|
+
|
249
|
+
export default {
|
250
|
+
|
251
|
+
data () {
|
252
|
+
|
253
|
+
return {
|
254
|
+
|
255
|
+
items: ''
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
},
|
260
|
+
|
261
|
+
async asyncData ({ $axios }) {
|
262
|
+
|
263
|
+
const data = await $axios.$get('https://websample.microcms.io/api/v1/news', {
|
264
|
+
|
265
|
+
headers: { 'X-API-KEY': 'b73987ce-4dc4-4f15-b310-134ce67fa219' }
|
266
|
+
|
267
|
+
})
|
268
|
+
|
269
|
+
return {
|
270
|
+
|
271
|
+
items: data.contents
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
</script>
|
282
|
+
|
283
|
+
```
|