I have a first function that sends commands and receives data. And a second function to download this data (with href and download). I have a third function that starts function one and then function two but I notice that function two is launched before function one. How do we solve this?
function third(){
first();
second();
}
function first(){
//sends and receives commands with websockets
}
function second(){
console.log("1");
let save = document.getElementById("photo");
console.log("2");
save.href = "http://my_url:my_port/folder/img.jpg";
console.log("3");
save.download = "";
console.log("4");
}
In my console, I can see console.log of the second function before the first function. Why ?
Thanks.