//const request = request('request');

// import * as request from 'request';

// const url = 'https://api.exchangeratesapi.io/latest';
// let result = '';
// request.get(url)
//     .on('respose', res => {
//         console.log(`statusCode = ${res.statusCode}`);
//     })
//     .on('data', data => {
//             console.log("ได้ข้อมูล")
//         result += data;
//     })
//     .on('end', res => {
//         console.log('yess');
//         console.log(result);
//         const exchange = JSON.parse(result);
//         console.log(exchange.rates);
//     })


import axios from 'axios';
axios
  .get("https://api.exchangeratesapi.io/latest")
  .then(response => {

    const r = response.data.rates;
    console.log(`เงิน 100 บาท = ${100*r.USD/r.THB} USD`);

  })
  .catch(err => {
    console.error(err)
  })



