Nice logger errors in Javascript

Member

adelia_boyer

by adelia_boyer , in category: JavaScript , 2 months ago

Nice logger errors in Javascript: if not ok? throw "something" šŸ˜ƒ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
const fetchOrders = (setOrders) => {
  fetch("/api/v1/orders/")
    .then(res => {
      if (!res.ok) throw "something";
      return res.json();
    })
    .then(list => {
      setOrders(list);
      toast.success("Tellimuste uuendamine Ƶnnestus :)");
    })
    .catch(() => {
      alert("error happened");
      toast.error("Ei Ƶnnestunud tellimuste pƤrimine");
    });
};

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers