fix api handling

master
Chakib Benziane 5 years ago
parent 4d764d057c
commit 24fec00864

@ -24,9 +24,6 @@ export async function lastSession(){
let res = await fetch(req)
.catch((e) => {console.error(e)})
if (!res.ok){
throw(`${res.status}: ` + (await res.json()).error)
}
return res.json()
}
@ -47,7 +44,7 @@ export async function checkUploadStatus(uploadId){
console.error(`${res.status}: ` + json.error)
}
return res.json().catch((e)=>{console.error(res.text())})
return res.json().catch((e)=>{console.error(e)})
}
export async function pollUploadStatus(uploadId){
@ -63,15 +60,7 @@ export async function pollUploadStatus(uploadId){
.catch((e) => {console.error(e)})
if (!res.ok){
let json = await res.json()
.catch((e)=>{
console.error(res.text())
})
console.error(`${res.status}: ` + json.error)
}
return res.json().catch((e)=>{console.error(res.text())})
return res.json().catch((e)=>{console.error(e)})
}
@ -105,10 +94,6 @@ class Upload {
.catch((e) => { console.error(e) })
if (!res.ok) {
throw(`${res.status}: ` + (await res.json()).error)
}
return res.json().then(data => {
let { upload_id: id } = data
this.uploadId = id
@ -138,10 +123,6 @@ class Upload {
let res = await fetch(req)
.catch((e) => {console.error(e)})
if (!res.ok){
throw(`${res.status}: ` + (await res.json()).error)
}
return res.json()
}
}

Loading…
Cancel
Save