1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 12:27:28 +00:00
cloudtube/html/static/js/local-video.js

19 lines
543 B
JavaScript
Raw Normal View History

2020-10-26 07:29:05 +00:00
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()
}
})