the server was encountered an error while retriving the data, and now we're here :3
- -please contact the administrator with this code
-error identifier: {{ errorMessage.code }}
-Streamers you follow
diff --git a/src/views/UserView.vue b/src/views/UserView.vue index fb637d7..6a3bc6b 100644 --- a/src/views/UserView.vue +++ b/src/views/UserView.vue @@ -5,61 +5,56 @@ import VideoPlayer from '@/components/VideoPlayer.vue' import TwitchChat from '@/components/TwitchChat.vue' import ErrorMessage from '@/components/ErrorMessage.vue' import FollowButton from '@/components/FollowButton.vue' +import LoadingScreen from '@/components/LoadingScreen.vue' export default { async setup() { const route = useRoute() const username = route.params.username const protocol = import.meta.env.VITE_HTTPS === 'true' ? 'https://' : 'http://' - + const getUser = async () => { - const res = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`) - - if (res.status !== 200) { + try { + const res = await fetch(`${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/api/users/${username}`) const data = await res.json() - - if (!data.code) { - return { - status: 'error', - code: 'error' - } - } - + return data + } catch (error) { + console.error(error) return { - ...data + status: 'error', } } - - const data = await res.json() - return data } const data = ref() - onMounted(async () => { - const fetchedUser = await getUser() - data.value = fetchedUser - }) + const videoOptions = { + autoplay: true, + controls: true, + sources: [ + { + src: `${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/proxy/stream/${username}/hls.m3u8`, + type: 'application/vnd.apple.mpegurl' + } + ], + fluid: true + } return { data, - videoOptions: { - autoplay: true, - controls: true, - sources: [ - { - src: `${protocol}${import.meta.env.VITE_BACKEND_DOMAIN}/proxy/stream/${username}/hls.m3u8`, - type: 'application/vnd.apple.mpegurl' - } - ], - fluid: true - } + videoOptions, + getUser } }, components: { - VideoPlayer, - TwitchChat, - ErrorMessage, - FollowButton + VideoPlayer, + TwitchChat, + ErrorMessage, + FollowButton, + LoadingScreen + }, + async mounted() { + const fetchedUser = await this.getUser() + this.data = fetchedUser }, methods: { truncate(value: string, length: number) { @@ -73,19 +68,12 @@ export default { } - -