내일 할일
1. 객체 생성 공부하기 - https://junspapa-itdev.tistory.com/22
2. 객체를 {코인가격: 코인이름} 이런식으로 만들어서 코인가격.sort()를 했을때 코인이름도 정렬되게 하기

한국코인 (영어이름, 한국어이름, 가격, 변동%) 변수에 저장

    allData: function(){

      // 코인 영어, 한글이름 배열에 담기
      axios.get('https://api.upbit.com/v1/market/all')
      .then(res => {
        for(var i=0; i<res.data.length-1; i++){
          if(res.data[i].market[0] === 'K'){ // 한국 코인만 가져오기
            this.allCoinEnglishName.push(res.data[i].market)
            this.allCoinKoreaName.push(res.data[i].korean_name)
          }
        }

        // 2번째 axios요청에서 this.allCoinEnglishName[i]를 할수 없어서 임시로 배열 만듬
        let eng = this.allCoinEnglishName

        // 2번째 axios요청에서 .push를 인식 못해서 문자열로 더해서 만든후 .split(",")로 배열로 바꿔서 변수에 넣음
        let price = '';
        let change = '';

        const countPrice = i => {

          if(i<eng.length)
          {
            setTimeout(function() {

              axios.get('https://api.upbit.com/v1/ticker?markets='+eng[i])
              .then(res2 => {
                price += res2.data[0].trade_price+","
                change += res2.data[0].change_rate+","
              })

              i++;
              countPrice(i)
            }, 150) // setTimeout 함수 종료
          } else
          {
            console.log("실행??")
            this.coinPrice.push(price.split(","))
            this.coinChange.push(change.split(","))
          }
        }
        countPrice(0) // 0번째 코인부터 마지막 코인까지 꺼내기 위해 0부터 시작

    }) // 맨처음 axios 함수 괄호

    }, // allData 함수 끝

+ Recent posts