1.1.5 • Published 5 years ago
qed-currencies-converter v1.1.5
QED Currency Converter
Install
npm i --save qed-currencies-converter
Preview (style-1)
import QedCurrencyConverter from 'qed-currencies-converter'
import 'qed-currencies-converter/dist/qed-currency-converter-style.css'
Preview (style-2)
import QedCurrencyConverter from 'qed-currencies-converter'
import 'qed-currencies-converter/dist/qed-currency-converter-style-2.css'
Usage
Import component
import QedCurrencyConverter from 'qed-currencies-converter'
import 'qed-currencies-converter/dist/qed-currency-converter-style.css'
const app = new Vue({
components: {
QedCurrencyConverter,
}
};
<div>
<qed-currency-converter :config="config"/>
</div>
Config Example
const config = {
// Api key for unlimited requests per minute -> api key is not required if you use your own rate provider
apiKey: 'here-comes-your-api-key',
// You can override default exchange api with your own route (response example json => { rate: 1.2 })
route:'/api/currencies/rate',
// Whether rate will be displayed (true/false)
displayRate:true,
// Currency list, iso name is sent to previously defined route ex ${route}?from="eur"&to="usd"
currencies: [
{
symbol:'$',
iso: 'usd'
},
{
symbol: '€',
iso: 'eur'
}
],
// Simple backup function if you do not want to use live rates, or in case your currency rate provider goes offline
backupRateFunction(from, to) {
if (from.iso == 'EUR' && from.iso == 'USD') {
return 1.12;
}
// else if () .......
return 1;
}
}
API KEY
- Api key is required only if you wish to use predefined api exchange rate provider with unlimited requests per minute
- This way all you have to do is set up list of currencies you wish to use on your site
- Api key is also free and can be obtained here -> https://exchange.qed.services