Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/splits-io. a speedrunning data store and analysis engine splits.io
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { getAccessToken } from '../token'
export default { data: () => ({ body: '', error: null, loading: false, }), methods: { chat: async function() { this.error = false this.loading = true
const headers = new Headers() headers.append('Content-Type', 'application/json') const accessToken = getAccessToken() if (accessToken) { headers.append('Authorization', `Bearer ${accessToken}`) }
try { const response = fetch(`/api/v4/races/${this.race.id}/chat`, { method: 'POST', headers: headers, body: JSON.stringify({ body: this.body, }) })
this.body = ''
if (!(await response).ok) { throw (await response.json()).error || response.statusText }
} catch(error) { this.error = error } finally { this.loading = false document.getElementById('input-chat-text').focus() } }, }, name: 'race-chat', props: ['race'],}