I am getting values from a distant table that I pushed into an array :
function getrecords(base, view) {
var tab = [];
var jsonTab = {};
base('Table 1').select({
view: view
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function(record) {
tab.push({
'Name':record.get('Name'),
'Notes': record.get('Notes')
});
});
//console.log(tab);
return tab;
});
}
Now, with promiseJs I made a promise function since the call is asynchronous:
function readRecords(base, view){
return new Promise(function(fulfill, reject){
getrecords(base, view, function (err, res){
if(err) reject(err);
else fulfill(res);
});
});
}
Now what I want to do is to use that tab! But when I create a var like that and console log it :
var tabRecord= readRecords(base, view);
console.log(tabRecord);
That's the result in cmd:
Promise { _45: 0, _81: 0, _65: null, _54: null }
What does it suppose to mean? Why haven't I the tab shown? What should I do in order to get the return value of my function?
Thank u all.
ps : I helped mysefl with this website https://www.promisejs.org/ to write the promise.