Feature/daisy UI (#28)
* Api and store * Add apis * Add daisy ui * Rename var
This commit is contained in:
1 parent
9031f51d5d
commit
be4ef44338
16 files changed
+1181
-139
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { getHost } from "./Host";
|
||||
|
||||
export class PlayletApi {
|
||||
static host = () => `http://${getHost()}`
|
||||
|
||||
static async getState() {
|
||||
const response = await fetch(`${PlayletApi.host()}/api/state`);
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
static async logout() {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "logout" });
|
||||
}
|
||||
|
||||
static async playVideo(videoId) {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "play", videoId: videoId });
|
||||
}
|
||||
|
||||
static async clearSearchHistory() {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/api/command`, { command: "clear-search-history" });
|
||||
}
|
||||
|
||||
static async updateInstances(instances) {
|
||||
return await PlayletApi.postJson(`${PlayletApi.host()}/invidious/instances`, instances);
|
||||
}
|
||||
|
||||
private static postJson(url, payload) {
|
||||
return fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user