the URL that gets the video information is returned asynchronously through the API background. So you need to get the url through the getDashInfo method, and then create the axios object, but the REST_BASEURL variable below is a Promise object, so let"s see where the code needs to be modified.
function getDashInfo(){
return new Promise((resolve,reject)=>{
getDashServerInfo().then(res=>{
console.log(res);
let dash;
let errCode=res.errCode;
if(errCode==0){
dash=res.data;
}
resolve(dash);
})
})
}
async function getBaseURL(){
let dash=await getDashInfo();
let url="";
let dataPort="";
if(dash.url.indexOf("https")!=-1){
dataPort=dash.httpsCmdPort;
}
else{
dataPort=dash.httpCmdPort;
}
url=dash.url+":"+dataPort;
return url;
}
let REST_BASEURL=getBaseURL();
const newAxios=axios.create({
baseURL:REST_BASEURL,
});