Vanilla fetch()

fetch($url)
  .then((res) => {
    if(!res.ok) {
      // check status, make decisions
    }
    return res.json()
  })
  .then((item) => {
    // process item
  })
  .catch((err) => {
    // handle the error
  });
}