cpularp-manager-frontend/src/ts/user_info.ts

35 lines
961 B
TypeScript
Raw Normal View History

import { reactive } from 'vue'
export const user_store = reactive({
avatar_decoration: '',
avatar: '',
id: '',
global_name: '',
username: '',
})
export function update_info() {
fetch('http://localhost:31337/dashboard', {
credentials: 'include',
})
.then((res) => {
res
.json()
.then((userjson) => {
console.log(userjson)
user_store.avatar_decoration =
'https://cdn.discordapp.com/avatar-decoration-presets/' +
userjson.avatar_decoration_data.asset +
'.png'
console.log(user_store)
user_store.avatar =
'https://cdn.discordapp.com/avatars/' + userjson.id + '/' + userjson.avatar + '.png'
user_store.id = 'https://discord.com/users/' + userjson.id
user_store.global_name = userjson.global_name
user_store.username = userjson.username
})
.catch(() => {})
})
.catch(() => {})
}