3.1.2 • Published 5 years ago

forexmm v3.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

FOREXMM

Myanmar Exchange Rate

Build Status code style: prettier npm contributions welcome License: MIT

http://forex.cbm.gov.mm/index.php/api does not allow CORS. This npm package help you to bypass CORS issue and to build Myanmar Exchange Rate API server.

Installation

npm install --save forexmm

API List

  • latest
  • currencies
  • history

latest

var forexmm = require('forexmm');
var latest = forexmm.latest;
latest()
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log(err);
  });

currencies

var forexmm = require('forexmm');
var currencies = forexmm.currencies;
currencies()
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log(err);
  });

history

var forexmm = require('forexmm');
var history = forexmm.history;
var date = new Date(2018, 1, 4);
history(date)
  .then(data => {
    console.log(data);
  })
  .catch(err => {
    console.log(err);
  });

Sample API Server Using Express.js

const express = require('express');
const app = express();
const PORT = process.env.PORT || 80;

const forexmm = require('forexmm');
const latest = forexmm.latest;
const currencies = forexmm.currencies;
const history = forexmm.history;

app.get('/latest', (req, res) => {
  latest()
    .then(data => {
      res.json(data);
    })
    .catch(err => {
      res.status(500).json({ err: err.message });
    });
});

app.get('/currencies', (req, res) => {
  currencies()
    .then(data => {
      res.json(data);
    })
    .catch(err => {
      res.status(500).json({ err: err.message });
    });
});

app.get('/history/:date', (req, res) => {
  let date = req.params.date;
  history(date)
    .then(data => {
      res.json(data);
    })
    .catch(err => {
      res.status(500).send({ err: err.message });
    });
});

app.all('*', (req, res) => {
  res.sendStatus(404);
});

app.listen(PORT, () => {
  console.log(`forexmm api server is running on port ${PORT}`);
});

Related

License

MIT © Aung Myo Kyaw

3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago