add Folder interface

This commit is contained in:
geoffrey45
2022-03-24 00:25:41 +03:00
parent f38f549f79
commit 642c524a08
6 changed files with 18 additions and 38 deletions
-24
View File
@@ -1,24 +0,0 @@
let base_uri = "http://127.0.0.1:9876/";
const getTracksAndDirs = async (path) => {
let url;
const encoded_path = encodeURIComponent(path.replaceAll("/", "|"));
url = url = `${base_uri}/f/${encoded_path}`;
const res = await fetch(url);
if (!res.ok) {
const message = `An error has occurred: ${res.status}`;
throw new Error(message);
}
const data = await res.json();
const songs = data.files;
const folders = data.folders;
return {songs, folders};
};
export default getTracksAndDirs;