-
Notifications
You must be signed in to change notification settings - Fork 0
/
public_apis.vue
96 lines (87 loc) · 2.3 KB
/
public_apis.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<template>
<div>
<section v-if="error" class="text-center">
<!-- The "error" scoped slot will be used if there is an error -->
<slot name="error">
<p>{{ error }}</p>
</slot>
</section>
<section v-else>
<div v-if="loading" class="text-center">
<!-- Use the "loading" slot to display a loading message -->
<slot name="loading">
<p>Loading...</p>
</slot>
</div>
<div v-else>
<div class="flex flex-wrap justify-between mx-4 my-8">
<div>
<!-- Use the "left" slot to display a custom control on the left -->
<slot name="left">
<feldm-public-apis-filter v-model="filters.category" />
</slot>
</div>
<div>
<!-- Use the "right" slot to display a custom control on the right -->
<slot name="right">
<feldm-public-apis-search v-model="filters.title" />
</slot>
</div>
</div>
<div v-if="apis && apis.length">
<feldm-public-apis-list :apis="apis" />
</div>
<div v-else class="text-center">No data available...</div>
</div>
</section>
</div>
</template>
<script>
import getEntries from "@/api/getEntries";
import FeldmPublicApisFilter from "@/components/public_apis/public_apis_filter.vue";
import FeldmPublicApisSearch from "@/components/public_apis/public_apis_search.vue";
import FeldmPublicApisList from "@/components/public_apis/public_apis_list.vue";
export default {
name: "FeldmPublicApis",
components: {
FeldmPublicApisFilter,
FeldmPublicApisSearch,
FeldmPublicApisList,
},
data() {
return {
apis: [],
loading: true,
error: '',
filters: {
title: '',
category: '',
},
};
},
watch: {
filters: {
// Callback handler when the filters are updated.
handler: function () {
this.fetchData();
},
deep: true,
},
},
created() {
this.fetchData();
},
methods: {
async fetchData() {
try {
const response = await getEntries(this.filters);
this.apis = response.data.entries;
} catch (err) {
this.error = err.toString();
} finally {
this.loading = false;
}
},
},
};
</script>