JavaScript AJAX Displaying the top JavaScript questions of the month from Stack Overflow's API

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


We can make an AJAX request to Stack Exchange's API to retrieve a list of the top JavaScript questions for the month, then present them as a list of links. If the request fails or the returns an API error, our promise error handling displays the error instead.

View live results on HyperWeb.
const url =
    '' +

fetch(url).then(response => response.json()).then(data => {
  if (data.error_message) {
    throw new Error(data.error_message);

  const list = document.createElement('ol');

  for (const {title, link} of data.items) {
    const entry = document.createElement('li');
    const hyperlink = document.createElement('a');

    hyperlink.textContent = title;
    hyperlink.href = link;
}).then(null, error => {
  const message = document.createElement('pre');
  document.body.appendChild(message); = 'red';

  message.textContent = String(error);

Got any JavaScript Question?