devYuraKim / react

udemy - jonas schmedtmann
0 stars 0 forks source link

c01-currency-converter | undefined object #4

Closed devYuraKim closed 3 months ago

devYuraKim commented 3 months ago
Screenshot 2024-08-07 at 5 35 04 PM

This error occurs when the app is loaded for the first time (=when amount input is empty) and when both currencies(base and result) are the same.

useEffect(
    function () {
      async function fetchData() {
        const host = "api.frankfurter.app";
        const res = await fetch(
          `https://${host}/latest?amount=${amount}&from=${from}&to=${to}`
        );
        const data = await res.json();
        const rates = data.rates[to];
        setResult(rates);
        console.log(result);
      }
      fetchData();
    },
    [amount, from, to, result]
  );
devYuraKim commented 3 months ago
  1. same currency https://github.com/hakanensari/frankfurter/issues/51

  2. amount=0 https://github.com/hakanensari/frankfurter/issues/55