Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Show HN: Free API service for crypto and foreign exchange rates.
``` fetch(url) .then((resp) => resp.json()) .then((data) => { console.log(data) }) ```
instead of
``` var requestURL = 'https://api.exchangerate.host/latest'; var request = new XMLHttpRequest(); request.open('GET', requestURL); request.responseType = 'json';
request.send(); request.onload = function() { var response = request.response; console.log(response); } ```
``` fetch(url) .then((resp) => resp.json()) .then((data) => { console.log(data) }) ```
instead of
``` var requestURL = 'https://api.exchangerate.host/latest'; var request = new XMLHttpRequest(); request.open('GET', requestURL); request.responseType = 'json';
request.send(); request.onload = function() { var response = request.response; console.log(response); } ```