Compare commits

..

2 Commits

Author SHA1 Message Date
Kar b9e6cbca02 API filter [_in] 2022-11-05 13:55:20 +05:30
Kar 5349e735bf api attachment 2022-11-05 12:50:05 +05:30
2 changed files with 65 additions and 24 deletions

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="flex flex-col h-screen justify-between">
<Header />
<main>
<router-view />

View File

@ -8,11 +8,20 @@
</div>
<div v-if="page[0].attachments">
<div v-html="page[0].attachments[0]"> </div>
<div v-if="files">
<h2>Attachments</h2>
<div v-for="(file, index) in files">
{{index+1}}<a :href="'https://api8.siliconpin.com/assets/' + file.directus_files_id">
<h3> {{ file.directus_files_id }}</h3>
</a>
</div>
<div>{{page[0].attachments[0]}}</div>
</div>
<!-- <div>{{page[0].attachments[0]}}</div> -->
</div>
</div>
</template>
@ -22,18 +31,50 @@
data() {
return {
page: null,
files: [],
isLoading: true
}
},
mounted: function () {
fetch('https://api8.siliconpin.com/items/scc22?filter[slug][_eq]=' + this.$route.params.id)
// fetch('https://api8.siliconpin.com/items/scc22?slug=about-us')
.then(response => response.json())
.then(data => {
this.page = data.data
console.log(data)
let attIDs = ''
let t = 0
this.page[0].attachments.forEach(ids => {
if (t == 0) attIDs = ids
else attIDs = attIDs + ',' + ids
t++
// console.log(ids)
});
// console.log(attIDs)
// this.getAttachments(this.page[0].attachments)
// console.log(this.page[0].attachments)
this.isLoading = false
fetch('https://api8.siliconpin.com/items/scc22_files_1?filter[id][_in]=' + attIDs)
.then(resp => resp.json())
.then(file => {
this.files = file.data
// attach.data.forEach(fileID=> this.files.push(fileID.directus_files_id))
console.log(file.data)
// this.attachments.push(attach.data[0].directus_files_id)
})
// console.log(Object.assign({}, this.files))
// console.log(this.files)
})
},
methods: {
// getAttachments(att) {
// console.log(att)
// // fetch('https://api8.siliconpin.com/items/ecom55?filter[slug][_eq]=' + this.$route.params.id)
// // .then(response => response.json())
// // .then(data => this.itemByCategory = data)
// // console.log(this.itemByCategory)
// }
}
}
</script>