Как дождаться исполнения .then

Как можно дождаться исполнения .then, когда a будет равна posts?

let a;

fetch('https://jsonplaceholder.typicode.com/posts')
  .then(response => response.json())
  .then(posts => a = posts || {});

console.log(a);

Я пробовал оборачивать fetch в асинхронную IIFE:

let a;

(async function() {
  const reponse = await fetch('https://jsonplaceholder.typicode.com/posts');
  const res = await response.json();
  a = res;
}());

console.log(a);


Ответы (0 шт):