How to give execute in typescript code one after another.
I have a two method in like
Mehod1 = () =>{
let url: string = getUrl;
var obj:Object[] = getData();
let tempObj: any = {};
for(let i=0; i<alphas.length; i++){
Object.assign(tempObj, obj[i]);
let data = {
Key1: tempObj.value1,
Key2 : tempObj.value2
};
this.callApi()({
url: url
method: "POST",
data
})
.then((data: any) => {
return data.data;
})
.catch((error: any) => {
throw error;
});
}
}
Mehod2= async () => {
//await Mehod1();
await Mehod1();
let url: string = getUrl;
let data = {
Key1: value1.
Key2 : value2
};
return this.callApi()({
url: url
method: "POST",
data
})
.then((data: any) => {
return data;
})
.catch((error: any) => {
throw error;
});
};
I am calling method2 first and from there I am calling method1. I want after executing all the index in loop in method 1 method2 other code should get execute.
What is happening only first index in getting execute in method 1 and then method 2 code is getting execute.
Any suggestion what should I can change.