Closed Poccu closed 9 months ago
Your browser is caching the data.
You can do something like this: https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/cny.json?d=2022-02-19
or
Add a random number or string at end or url to fetch latest data https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/cny.json?rand=2343
I prefer appending date at end, because the rates are updated daily.
const UTCDateStr = new Date().toISOString().substring(0,10)
const avoidCache = '?d='+UTCDateStr
const url = 'https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/cny.json'
fetch(url+avoidCache).then(res=>res.json()).then(console.log);
It works! Thanks a lot for the quick response :)
currency-api has stopped working, Please read the migration guide
Sometimes I get jsons with the wrong date on the "latest" request. Today is
2022-02-19
Example:
https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/cny.json
console.log
on the project showing:Also I tried to get
xxx.min.json
instead ofxxx.json
If we open URL
https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/rub.min.json
everything is okayBut when I
console.log
it on my project it showsCan you tell me what the problem is?
I'm trying to get the difference of exchange rates between the last two days -
latest
and(today - 1) day
. So this is the problem for me.