1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-04-25 23:28:50 +02:00
Ondřej Synáček b28995aa1e feature: convert form input to Svelte component and create module for
fetching event data & parsing it
2020-12-20 13:50:12 +01:00

24 lines
634 B
JavaScript

export const postURL = (data) => {
return new Promise((resolve, reject) => {
fetch('/download/html/', {
method: 'POST',
headers: {
'Accept': 'text/html, application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data,
}).then((response) => {
if (response.status !== 200) {
if (response.body.constructor === ReadableStream) {
response.json().then((json) => reject(json.error || response.statusText))
return
}
reject(response.statusText)
return
}
resolve(response)
}).catch(reject)
})
}