Switched to Composition API

This commit is contained in:
Shiny Nematoda 2022-04-15 15:29:43 +05:30
parent 75b0a9b319
commit 8ee03fa623
11 changed files with 705 additions and 647 deletions

34
src/scripts/fetch.js Normal file
View file

@ -0,0 +1,34 @@
export function getPipedQuery() {
const papi = new URLSearchParams(location.search).get('pipedapi')
if (!papi) {
return ''
}
return '?pipedapi=' + papi
}
export async function getJson(url) {
const res = await fetch(url).then((res) => res.json()).catch(err => { alert(err) });
if (!res.error) {
return res;
} else {
alert(
res.message
.replaceAll('Video', 'Audio')
.replaceAll('video', 'audio')
.replaceAll('watched', 'heard'),
);
console.error(res.message);
}
}
export async function getJsonPiped(path) {
const root =
new URLSearchParams(location.search).get('pipedapi') ||
localStorage.getItem('pipedapi') ||
'pipedapi.kavin.rocks';
return await getJson('https://' + root + path);
}