fawazahmed0 / exchange-api

Free Currency Exchange Rates API with 200+ Currencies & No Rate Limits
https://github.com/fawazahmed0/exchange-api#readme
Creative Commons Zero v1.0 Universal
720 stars 46 forks source link

currency converter api was not working sir.... #105

Open ShekhFaisal26 opened 2 months ago

ShekhFaisal26 commented 2 months ago

brother please help.. i am new to programing. just making currency converter. you have migrated the files to github. I want to use this link https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json in my code but i can't. so as per the given instructions i figured out a little bit and i was able to make this link https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/inr.json but at the last of this link i need usd/inr.json Plz help me out

kaifmohamad5543 commented 1 month ago

bro do u have another api for currency converter

fawazahmed0 commented 1 month ago

please read the migration

kaustubh-tripathi-1 commented 4 weeks ago

brother please help.. i am new to programing. just making currency converter. you have migrated the files to github. I want to use this link https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur/jpy.json in my code but i can't. so as per the given instructions i figured out a little bit and i was able to make this link https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/inr.json but at the last of this link i need usd/inr.json Plz help me out

Try this brother, it's working


const baseURL = `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies`;

const URL = `${baseURL}/${fromCurrency}.json`;

// Use it in async func. obviously
try {
        let response = await fetch(URL);

        let responseJSON = await response.json();

        let rate = responseJSON[fromCurrency][toCurrency];

        if (!response.ok) {
            throw new Error(`Network response was not ok`);
        }
    } catch (error) {
        msg.innerHTML = `Failed to fetch exchange rate. Try again later.`;
        console.error("Fetch error:", error);
        return;
    }