1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-02 10:41:36 +00:00

Add local fetch option

This commit is contained in:
Cadence Ember 2020-10-26 20:29:05 +13:00
parent f78ee4ff0f
commit 9a890574d5
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
7 changed files with 107 additions and 45 deletions

View file

@ -0,0 +1,18 @@
import {q} from "./elemjs/elemjs.js"
const status = q("#status")
const form = q("#form")
const data = q("#video-data")
fetch(`http://localhost:3000/api/v1/videos/${id}`).then(res => res.json()).then(root => {
if (root.error) throw new Error(root)
data.value = JSON.stringify(root)
form.submit()
status.textContent = "Submitting..."
}).catch(e => {
if (e.message.includes("NetworkError")) {
status.textContent = "Connection failed. Make sure you're running your own instance locally."
} else {
status.innerText = e.toString()
}
})