Closed wywywywy closed 12 months ago
Makes sense to me, thanks for your contribution!
@wywywywy Also consider adding fallback mechanism in your code:
Here is a JS example for fetching usd
to eur
rate:
const fetchWithFallback = async (links,obj) => {
let response;
for(let link of links)
{ try{
response = await fetch(link,obj)
if(response.ok)
return response
}catch(e){}
}
return response
}
let from = `usd`
let to = `eur`
fetchWithFallback([
`https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${from}/${to}.min.json`,
`https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/${from}/${to}.json`,
`https://raw.githubusercontent.com/fawazahmed0/currency-api/1/latest/currencies/${from}/${to}.min.json`,
`https://raw.githubusercontent.com/fawazahmed0/currency-api/1/latest/currencies/${from}/${to}.json`
]).then(res => res.json()).then(console.log)
So currency exchange is broken right now, because exchangerate.host now requires an API key.
I propose that we migrate to fawazahmed0/currency-api instead, because:
The risk is that @fawazahmed0 may stop maintaining it one day. But this is in my opinion a lower and less likely risk than a commercial provider start charging their free customers.