client: implement queuing

This commit is contained in:
geoffrey45
2021-12-21 13:42:06 +03:00
parent 8a744ce0be
commit 36999d8061
17 changed files with 240 additions and 179 deletions
+27
View File
@@ -0,0 +1,27 @@
const url = "http://127.0.0.1:9876/get/queue";
const getQueue = async (type, id) => {
const res = await fetch(url, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
type: type,
id: id,
}),
});
if (!res.ok) {
const message = `An error has occured: ${res.status}`;
throw new Error(message);
}
const data = await res.json();
localStorage.setItem("queue", JSON.stringify(data.songs));
return data.songs;
};
export default getQueue;