You need to call Fn1 before Fn2 to access it's value, so let's wrap Fn1 into Promise:
App = {
st: null,//st is number value
Fn1: function() {
return new Promise((resolve, reject) => {
App.contracts.contractName.deployed().then(function(instance){
return instance.getST();
}).then(function(result){
App.st = result;
resolve();
}).catch(function(err){
reject(err);
})
})
},
Fn2: function() {
alert(App.st)
}
}
or better with async/await:
App = {
st: null,//st is number value
Fn1: async function() {
try {
const instance = await App.contracts.contractName.deployed();
const result = await instance.getST();
App.st = result;
} catch(err) {
throw err;
}
},
Fn2: function() {
alert(App.st)
}
}
Now you can wait until Fn1 exec before calling Fn2:
App.Fn1().then(function() {
App.Fn2()
})
or using async/await:
await App.Fn1()
App.Fn2()
App.Fn2()?