I'd like to have the loadConfig function async and just finish after the resource has been loaded. await fetchetc. How can I declare it in this object syntax as an async function?
var QMEM = QMEM || { config : null, loadConfig : function(url) { console.log('url = ', url); fetch(url) .then(res => res.json()) .then(out => { this.config = out; }) .catch(err => console.log(err)); }, logConfig : function() { console.log('current configuration:\n', this.config); } }; QMEM.loadConfig(myConfigUrl); QMEM.logConfig();
asyncbeforefunction? Is that what you're asking?asyncoperations? Also note thatthisin the finalthencall will not be a reference to the outer object. You'll need to amend the scope