How do you properly type a fetch GET request?

more like this,

function expandUrl() {
  const urlToExpand = url + '?shortUrl=' + $inputField.val() + '&key=' + apiKey;

  fetch(urlToExpand).then(response => {
    if (response.ok) {
      return response.json();
    }
  }).then(data=>console.log(data));
}

remember that fetch itself returns a promise, and that promise is what you are chaining the .then to

1 Like