market.js
810 Bytes
const fetch = require('node-fetch');
const fs = require('fs');
const url = 'https://api.upbit.com/v1/market/all?isDetails=false';
const options = {method: 'GET', headers: {Accept: 'application/json'}};
fetch(url, options)
.then(res => res.json())
.then(json => {
var coinName = [];
var j = 0;
var file = 'coin_name.txt';
fs.open(file,'w',function(err,fd){
if(err) throw err;
});
for (i=0;i<json.length;i++) {
if (json[i].market.indexOf("KRW")>-1){
console.log(json[i].market);
coinName[j] = json[i].market;
j=j+1;
}
}
console.log(coinName);
fs.writeFile(file,coinName,'utf8',function(error){
console.log('write end')
});
})
.catch(err => console.error('error:' + err));