mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Add local fetch option
This commit is contained in:
parent
f78ee4ff0f
commit
9a890574d5
7 changed files with 107 additions and 45 deletions
18
html/static/js/local-video.js
Normal file
18
html/static/js/local-video.js
Normal 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()
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue