mirror of
https://codeberg.org/Hyperpipe/Hyperpipe
synced 2025-06-28 05:08:00 +02:00
Switched to Composition API
This commit is contained in:
parent
75b0a9b319
commit
8ee03fa623
11 changed files with 705 additions and 647 deletions
34
src/scripts/fetch.js
Normal file
34
src/scripts/fetch.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue