Nuxt.js+axios - 정적 JSON 파일에서 API 응답을 시뮬레이션하는 예
static/users.json
[
{
"id" : 1,
"name": "Alice"
},
{
"id" : 2,
"name": "Bob"
},
{
"id" : 3,
"name": "Carol"
}
]
pages/axios-assets-json.vue<template>
<div>
<h1>
assset API
</h1>
<h2>Users</h2>
<ul>
<li v-for="user in users" :key="user.id">
{{ user.id }} - {{ user.name }}
</li>
</ul>
</div>
</template>
<script>
import axios from 'axios'
export default {
async asyncData({ $axios }) {
const users = await $axios.$get('/users.json')
// OR
// const users = await $axios.$get('http://localhost:3000/axios-assets-json')
return { users }
}
}
</script>
Original by Github issue
Reference
이 문제에 관하여(Nuxt.js+axios - 정적 JSON 파일에서 API 응답을 시뮬레이션하는 예), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/YumaInaura/items/1c306286fc0e683c105a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(Nuxt.js+axios - 정적 JSON 파일에서 API 응답을 시뮬레이션하는 예), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/YumaInaura/items/1c306286fc0e683c105a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)