Nuxtの server/ ディレクトリに記載されたAPIから状態を取得します。
Http Rest APIから状態を取得します。
nuxt.config に事前に登録したサーバーに対してのみリクエスト可能です。
URI | {protocol}://{**name} |
---|---|
Scheme | {custom protocol} |
Path | nuxt.config.ts に登録されたPrefixの後に続くパスを記載します。 |
Example | reqres://users |
nuxt.config.ts にカスタム プロトコルを登録します
export default defineNuxtConfig({
combadge: {
protocol: {
reqres: {
type: "fetch",
prefix: "https://reqres.in/api/",
},
}
}
})
登録した State URI を利用します。
id | first_name | last_name | avatar | |
---|---|---|---|---|
1 | george.bluth@reqres.in | George | Bluth | ![]() |
2 | janet.weaver@reqres.in | Janet | Weaver | ![]() |
3 | emma.wong@reqres.in | Emma | Wong | ![]() |
4 | eve.holt@reqres.in | Eve | Holt | ![]() |
5 | charles.morris@reqres.in | Charles | Morris | ![]() |
6 | tracey.ramos@reqres.in | Tracey | Ramos | ![]() |
<template>
<b-table striped>
<thead>
<tr>
<th scope="col">
id
</th>
<th scope="col">
email
</th>
<th scope="col">
first_name
</th>
<th scope="col">
last_name
</th>
<th scope="col">
avatar
</th>
</tr>
</thead>
<tbody>
<c-list-item
v-slot="{ item }"
tag="tr"
state-src="reqres://users"
state-path="data"
>
<td>{{ item.id }}</td>
<td>{{ item.email }}</td>
<td>{{ item.first_name }}</td>
<td>{{ item.last_name }}</td>
<td>
<b-img
:src="item.avatar"
/>
</td>
</c-list-item>
</tbody>
</b-table>
</template>