Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lemonnekogh/lemonneko-currency-converter
A simple api to convert source currency to target currency.
https://github.com/lemonnekogh/lemonneko-currency-converter
Last synced: 11 days ago
JSON representation
A simple api to convert source currency to target currency.
- Host: GitHub
- URL: https://github.com/lemonnekogh/lemonneko-currency-converter
- Owner: LemonNekoGH
- License: mit
- Created: 2021-01-15T13:36:21.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-16T04:54:14.000Z (almost 4 years ago)
- Last Synced: 2024-04-24T04:56:09.469Z (8 months ago)
- Language: TypeScript
- Size: 73.2 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @lemonneko/currency-converter
A simple api to convert source currency to target currency.Exchange rate data is from: [prebid](https://github.com/prebid/currency-file)
## Simple use
### Node.js
install by npm
```
npm install @lemonneko/currency-converter
```
or yarn
```
yarn add @lemonneko/currency-converter
```
then, in your javascript file:```js
import {converter} from "@lemonneko/currency-converter";await converter.convert({
to: "USD",
from: "CNY",
amont: "1.234"
}).then((ressult) => {
// get the result
}).catch((err) => {
// catch the error
})
```## API Reference
### Functions
```
converter.convert(data: RequestData): Promise
```
### Interfaces
```js
interface ResultData {
result: string;
to: string;
from: string;
updated: string;
}
interface RequestData {
amount: string;
to: string;
from: string;
}
```
### Errors may produce
This error will produce when currency is not support.Error message like this:
```
Error: unsupported currency:
```
This error will produce when the network slow or not connect.Error message like this:
```
Error: connection timeout
```
#### Other error
Please make an issue.## Build && Test
build
```
yarn run build
```
test
```
yarn run test
```