I have a promise set like that
async filterProject(Valuetofilter, uid) {
var params = [this.db_name, parseInt(uid), this.password, 'project.project', 'search', [[['name', 'like', Valuetofilter]]]];
var client = xmlrpc.createClient({ host: this.host, port:this.port, path: '/xmlrpc/2/object' })
return new Promise((resolve, reject) => {
client.methodCall('execute_kw', params, function(err, data) {
if (err) {
reject(err)
}
else {
resolve(data)
}
})
})
}
then I call it like this
sd = new OdoooRpc('localhost', '8089', 'test', 'test', 'test');
var test = ''
var asdd = sd.authenticate().then(
(uid) => {
sd.filterProject('BF', uid)
.then((ids) => {
//console.log(ids)
sd.readProjects(ids, uid)
.then((records) =>{
test = records
//console.log(records)
})
}
)
}
);
console.log(asdd, test)
The problem is that test
never gets updated as console log return
I really need to valorize the global variable, I have been searching this issue on stackoverflow for the past 2 days but I didnt find any solution. Is a promise the best approach here?