전현진

Delete market.js

Showing 1 changed file with 0 additions and 27 deletions
1 -const fetch = require('node-fetch');
2 -const fs = require('fs');
3 -const url = 'https://api.upbit.com/v1/market/all?isDetails=false';
4 -const options = {method: 'GET', headers: {Accept: 'application/json'}};
5 -
6 -fetch(url, options)
7 - .then(res => res.json())
8 - .then(json => {
9 - var coinName = [];
10 - var j = 0;
11 - var file = 'coin_name.txt';
12 - fs.open(file,'w',function(err,fd){
13 - if(err) throw err;
14 - });
15 - for (i=0;i<json.length;i++) {
16 - if (json[i].market.indexOf("KRW")>-1){
17 - console.log(json[i].market);
18 - coinName[j] = json[i].market;
19 - j=j+1;
20 - }
21 - }
22 - console.log(coinName);
23 - fs.writeFile(file,coinName,'utf8',function(error){
24 - console.log('write end')
25 - });
26 - })
27 - .catch(err => console.error('error:' + err));
...\ No newline at end of file ...\ No newline at end of file