Myanmar Exchange Rate
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.
npm install --save forexmm
- latest
- currencies
- history
var forexmm = require('forexmm');
var latest = forexmm.latest;
latest()
.then(data => {
console.log(data);
})
.catch(err => {
console.log(err);
});
var forexmm = require('forexmm');
var currencies = forexmm.currencies;
currencies()
.then(data => {
console.log(data);
})
.catch(err => {
console.log(err);
});
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);
});
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}`);
});
MIT © Aung Myo Kyaw