Fix error message and use new backend response
This commit is contained in:
parent
a8ae6be436
commit
250697448c
@ -23,10 +23,12 @@ export default {
|
||||
const res = await fetch(
|
||||
`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/discover/${game}`
|
||||
)
|
||||
if (!res.ok) {
|
||||
return (this.data = { status: 'error' })
|
||||
const rawData = await res.json()
|
||||
if (rawData.status === "ok") {
|
||||
this.data = rawData.data
|
||||
} else {
|
||||
this.data = { status: 'error' }
|
||||
}
|
||||
this.data = await res.json()
|
||||
} catch (err) {
|
||||
this.data = { status: 'error' }
|
||||
console.error(err)
|
||||
|
@ -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' }
|
||||
|
@ -12,22 +12,6 @@ export default {
|
||||
const route = useRoute()
|
||||
const username = route.params.username
|
||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
||||
|
||||
const getUser = async () => {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`
|
||||
)
|
||||
const data = await res.json()
|
||||
return data
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return {
|
||||
status: 'error'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const data = ref()
|
||||
const videoOptions = {
|
||||
autoplay: true,
|
||||
@ -46,7 +30,7 @@ export default {
|
||||
return {
|
||||
data,
|
||||
videoOptions,
|
||||
getUser
|
||||
protocol
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@ -57,8 +41,22 @@ export default {
|
||||
LoadingScreen
|
||||
},
|
||||
async mounted() {
|
||||
const fetchedUser = await this.getUser()
|
||||
this.data = fetchedUser
|
||||
const username = this.$route.params.username
|
||||
const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://'
|
||||
|
||||
try {
|
||||
const res = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`)
|
||||
const rawData = await res.json()
|
||||
if (rawData.status === "ok") {
|
||||
this.data = rawData.data
|
||||
} else {
|
||||
this.data = { status: 'error' }
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
this.data = { status: 'error' }
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
truncate(value: string, length: number) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user