Item images
This commit is contained in:
parent
ad4311d052
commit
87fca8dff2
|
@ -9,7 +9,9 @@
|
|||
<ion-card v-for="item of collectionsStore.items" :key="item.id">
|
||||
<ion-card-title v-if="item.title"> {{ item.title }} </ion-card-title>
|
||||
<ion-card-title v-else>Item não possui título</ion-card-title>
|
||||
<ion-card-content></ion-card-content>
|
||||
<ion-card-content>
|
||||
<ion-img :src="item.thumbnail.medium[0]" :alt="item.title"></ion-img>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
</base-layout>
|
||||
</template>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import axios from 'axios'; //substitui o fetch
|
||||
import axios from 'axios';
|
||||
|
||||
const useCollectionsStore = defineStore('collections', {
|
||||
state () {
|
||||
|
@ -7,6 +7,8 @@ const useCollectionsStore = defineStore('collections', {
|
|||
collections: [],
|
||||
items: [],
|
||||
urlMuseum: '',
|
||||
userLogin: '',
|
||||
userPassword: '',
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -21,11 +23,21 @@ const useCollectionsStore = defineStore('collections', {
|
|||
return err;
|
||||
}
|
||||
},
|
||||
async fetchFullCollections() {
|
||||
try {
|
||||
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collections`);
|
||||
this.collections = response.data;
|
||||
} catch (err) {
|
||||
this.collections = [];
|
||||
console.error('Erro no carregamento das coleções:', err);
|
||||
return err;
|
||||
}
|
||||
},
|
||||
|
||||
async fetchItems(collectionId :string) {
|
||||
try {
|
||||
this.items = [];
|
||||
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collection/${collectionId}/items?perpage=12&orderby=modified`);
|
||||
const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collection/${collectionId}/items?perpage=12&orderby=modified&fetch_only=id,title,thumbnail`);
|
||||
this.items = response.data.items;
|
||||
} catch (err) {
|
||||
this.items = [];
|
||||
|
|
Loading…
Reference in New Issue