1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-09-20 03:07:28 +00:00
cloudtube/html/static/js/local-video.js
2020-10-26 20:29:05 +13:00

19 lines
543 B
JavaScript

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()
}
})