fetch('www.example.com/data') .then((res) => { if (!res.ok) { throw new Error('Error' + res.status) } return res.json() }).then((data) => { console.log('Data', data) }).catch((error) => { console.error('Error', error) })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter