How can I set window variables from inner side of async self excuting function. When I use await just before fetch, I get "error: Uncaught ReferenceError: bar is not defined". When I removed the await, in that case, I get the Promise object.
(async function (w){
bar = await fetch('https://jsonplaceholder.typicode.com/posts').then(()=>{
response.json()
}).then((data)=>{
return data
});
w.bar=bar;
})(window);
console.log(bar);