test6.js 862 Bytes
const fetch = require('node-fetch');
const url = 'https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT';
const options = {method: 'GET', headers: {Accept: 'application/json'}};
const rp = require('request-promise');
const requestOptions = {
  method: 'GET',
  uri: 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest',
  qs: {
    'start': '1',
    'limit': '10',
    'convert': 'KRW'
  },
  headers: {
    'X-CMC_PRO_API_KEY': 'c2f8e0b0-a253-4de3-a63f-9f564c8cdd1f'
  },
  json: true,
  gzip: true
};
fetch(url, options)
  .then(res => res.json())
  .then(json => 
    rp(requestOptions).then(response =>{
      var i=0;
      while(response.data[i].id !== 825){
        i = i+1;
      }
      console.log('API call response:', json.price*response.data[i].quote.KRW.price);
    })
    
  )
  .catch(err => console.error('error:' + err));