Fetch API

Error handling

try {
    let r = await fetch("/foo")
    if (!r.ok) { throw r }
    let data = await r.json()
} catch (e) {
    alert(e.statusText || e.message)
}