I'm new in javascript so I try to Use an API to delete vocal from a song, so I want to make some check if splitstatus
is success
I will call function getlink
, but if splitstatus
is progress
I will keep checking it until the splitstatus
is success and call function getlink
after it. But when I run my code the result only return "check 1".
For additional information that splitstatus only have 2 result "success" or "progress" and inside the splitlink
is http links
This is my code
var vidid = "";
var splitstatus = "";
var splitlink = "";
function ceksplit(x) {
setTimeout(function () {
axios.get(`https://www.lalal.ai/api/check/?id=${x}`).then((res) => {
splitstatus = res.data.task.state;
});
}, 30000);
}
function getlink(x) {
axios.get(`https://www.lalal.ai/api/check/?id=${x}`).then((res) => {
splitlink = res.data.split.accompaniment;
});
}
app.post("/uploads", async(req, res) => {
await ceksplit(vidid);
console.log("cek 1");
if (splitstatus === "progress") {
await ceksplit(vidid);
console.log("cek 2");
}
if (splitstatus === "progress") {
await ceksplit(vidid);
console.log("cek 3");
}
if (splitstatus === "progress") {
await ceksplit(vidid);
console.log("cek 4");
}
if (splitstatus === "progress") {
await ceksplit(vidid);
console.log("cek 5");
}
if (splitstatus === "success") {
await getlink(vidid);
console.log(splitlink);
}
});
Can someone help me? hope you guys understand what I'm asking, thanks:D.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…