Showing
1 changed file
with
0 additions
and
33 deletions
test.js
deleted
100644 → 0
| 1 | -const fetch = require('node-fetch'); | ||
| 2 | -var fs = require('fs'); | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -fs.readFile('coin_name.txt', 'utf8', function(err,data){ | ||
| 7 | - arr = data.split(","); | ||
| 8 | - // console.log(arr); | ||
| 9 | - var responseList = new Array(); | ||
| 10 | - for(j=0;j<2;j++){ | ||
| 11 | - for(i=j*10;i<(j+1)*10;i++){ | ||
| 12 | - (function(i){ | ||
| 13 | - setTimeout(function(){ | ||
| 14 | - const url = 'https://api.upbit.com/v1/candles/minutes/1?market='+arr[i]+'&count=1'; | ||
| 15 | - const options = {method: 'GET', headers: {Accept: 'application/json'}}; | ||
| 16 | - var coinJson = new Object(); | ||
| 17 | - fetch(url, options) | ||
| 18 | - .then(res => res.json()) | ||
| 19 | - .then(json => { | ||
| 20 | - coinJson.coin = arr[i]; | ||
| 21 | - coinJson.price = json[0].trade_price; | ||
| 22 | - responseList.push(coinJson); | ||
| 23 | - // console.log(responseList) | ||
| 24 | - console.log(i) | ||
| 25 | - }) | ||
| 26 | - .catch(err => console.error('error:' + err)); | ||
| 27 | - },i*10); | ||
| 28 | - })(i); | ||
| 29 | - } | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - | ||
| 33 | -}) |
-
Please register or login to post a comment