mirror of
https://github.com/fawazahmed0/exchange-api.git
synced 2025-06-29 18:21:14 +00:00
Update MIGRATION.md
This commit is contained in:
parent
c15afe69b1
commit
0e8e277124
21
MIGRATION.md
21
MIGRATION.md
@ -1,16 +1,15 @@
|
||||
### Migration Guide
|
||||
1. Change the URL from `https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/{date}/{endpoint}`<br> to<br> `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@{date}/v1/{endpoint}`
|
||||
|
||||
2. There is no `/currencies/{currencyCode}/{currencyCode}` endpoint in this new API, so please only use `/currencies/{currencyCode}` endpoint. For example:
|
||||
|
||||
```js
|
||||
json = fetchJSON(`/currencies/{fromCurrency}/{toCurrency}`)
|
||||
rate = json[toCurrency]
|
||||
1. Change the URL
|
||||
```diff
|
||||
- https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/{date}/{endpoint}
|
||||
+ https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@{date}/v1/{endpoint}
|
||||
```
|
||||
becomes
|
||||
```js
|
||||
json = fetchJSON(`/currencies/{fromCurrency}`)
|
||||
rate = json[fromCurrency][toCurrency]
|
||||
2. Change all `/currencies/{currencyCode}/{currencyCode}` endpoints to `/currencies/{currencyCode}` endpoint.
|
||||
```diff
|
||||
- json = fetchJSON(`/currencies/{fromCurrency}/{toCurrency}`)
|
||||
+ json = fetchJSON(`/currencies/{fromCurrency}`)
|
||||
- rate = json[toCurrency]
|
||||
+ rate = json[fromCurrency][toCurrency]
|
||||
```
|
||||
|
||||
3. (Optional Step) Add [Fallback mechanism](https://github.com/fawazahmed0/exchange-api/blob/main/README.md#additional-fallback-url-on-cloudflare:~:text=Additional%20Fallback%20URL%20on%20Cloudflare%3A) in your code, to avoid any issue in the future.
|
||||
|
Loading…
Reference in New Issue
Block a user