Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

Myanmar Exchange Rate npm

Topics

Resources

License

Releases

No releases published

Packages

No packages published