Read operation on operation id got from azure read api
I am trying to read the data in operation id url but for that I have to use settimeout function and set some time , if I use it without settimeout it alway's shows status is runing .
const read_result = (opid) => {
var dlres;
var config = {
method: 'get',
url: opid,
parameters:{
operationId:opid
},
headers: {
'Ocp-Apim-Subscription-Key': 'my key'
},
};
axios(config)
.then(function (response) {
console.log("\n");
console.log("\n");
console.log(response.status);
// console.log(response.data.analyzeResult.readResults[0].lines[1].text);
dlres = response.data;
})
.catch(function (error) {
console.log("there is error ", error);
});
return dlres;
}
this is my code, I want to know how to make it wait till the response status become "succeed" and then return.