fetch('http://example.com') .then(response => response.text()) .then(data => console.log(data)) .catch(err => console.error(err)); /* for JSON, use response.json() on the 2nd line */