We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { useEffect, useState } from "react";
function useCurrencyInfo(currency) { const [data, setData] = useState({}); const [error, setError] = useState(null);
useEffect(() => { const fetchData = async () => { try { const response = await fetch(`https://cdn.jsdelivr.net/npm/@fawazahmed0/[email protected]/v1/currencies/${currency}.json`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const result = await response.json(); setData(result[currency]); } catch (err) { setError(err.message); console.error("Fetch error: ", err); } }; fetchData(); }, [currency]); if (error) { return { error }; } return data;
}
export default useCurrencyInfo;
I'm doing this way to solve
The text was updated successfully, but these errors were encountered:
great
Sorry, something went wrong.
No branches or pull requests
import { useEffect, useState } from "react";
function useCurrencyInfo(currency) {
const [data, setData] = useState({});
const [error, setError] = useState(null);
}
export default useCurrencyInfo;
I'm doing this way to solve
The text was updated successfully, but these errors were encountered: