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"); }); }; |