Skip to content

Updated the currency API #311

@rehan2003gupta

Description

@rehan2003gupta

The new API is :- [(https://v6.exchangerate-api.com/v6/ff7f40c44ff6bb383af60905/latest/${currency})]

//This is the code snippet if you want to update the existing code

import { useEffect, useState } from "react";

function useCurrencyInfo(currency) {
const [data, setData] = useState({});

useEffect(() => {
fetch(https://v6.exchangerate-api.com/v6/ff7f40c44ff6bb383af60905/latest/${currency})
.then((res) => res.json())
.then((res) => {
if (res.result === "success") {
setData(res.conversion_rates); // ✅ fix: correct data path
} else {
setError("Failed to fetch currency data");
}
})
.catch((err) => {
console.log("ERROR :- FETCHING API")
});
}, [currency]);

return data; // return loading & error if needed
}

export default useCurrencyInfo;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions