Fix error message and use new backend response

This commit is contained in:
dragongoose
2023-04-10 11:55:41 -04:00
parent a8ae6be436
commit 250697448c
3 changed files with 28 additions and 27 deletions

View File

@ -44,8 +44,6 @@ export default {
const [set1, set2] = [new Set(wantedTags), new Set(tags)]
const common = [...set1].filter((x) => set2.has(x))
console.log(wantedTags)
if (common.length === wantedTags.length) {
category.style.display = ''
} else if (wantedTags[0] === '') {
@ -91,10 +89,13 @@ export default {
try {
const res = await fetch(`${this.protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/discover`)
if (!res.ok) {
throw new Error('Failed to fetch data')
const rawData = await res.json()
if (rawData.status === "ok") {
this.data = rawData.data
} else {
this.data = { status: 'error' }
}
this.data = await res.json()
} catch (error) {
console.error(error)
this.data = { status: 'error' }