From ae4d55419147a7f760fbaa360af2a277c18e441f Mon Sep 17 00:00:00 2001 From: jihyun jo Date: Fri, 2 Feb 2024 09:56:13 +0900 Subject: [PATCH] getTable replace .forEach to for...of --- src/views/Summery.vue | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/views/Summery.vue b/src/views/Summery.vue index 7a100dc..fb39ffb 100644 --- a/src/views/Summery.vue +++ b/src/views/Summery.vue @@ -14,13 +14,15 @@ export default { // 파이프라인 리스트 호출한 결과값을 data 파일에 저장 this.pipelineList = (await pipeline()).data.data; - // 유아이 추출할때 사용할 코드 + // 필터 유아이 추출할때 사용할 코드 // 데이터 파일 list 에 map 을 돌려서 그 안에 key 값을 추출 // map object 형으로 한번에 추출하기 - const getName = this.pipelineList.map((item)=>item.name); - console.log(getName); - const getKey = this.pipelineList.map((item)=>item.key); - console.log(getKey) + // const getName = this.pipelineList.map((item)=>item.name); + // console.log(getName); + // const getKey = this.pipelineList.map((item)=>item.key); + // console.log(getKey) + const [names, keys] = this.pipelineList.map(item => [item.name, item.key]); + console.log(names, keys) @@ -28,15 +30,14 @@ export default { }, async getTable(){ // pipelineList 에서 key 값을 뽑아내서 - this.pipelineList.map((item)=>item.key) - // key 를 넣어 매치시켜 불러온 table data 를 response 에 받음 - .forEach(async (pipelineKey) => { - const response = (await table(pipelineKey)).data.data - // 테이블 배열을 1차원으로 정렬해준다. - response.forEach(item => this.tableList.push(item)) - // 테이블 배열을 2차원으로 정렬한다. - // this.tableList.push(response) - }) + // 이터레이터 문법 for ... of 사용 + for (const pipelineKey of this.pipelineList.map((item) => item.key)) { + const response = (await table(pipelineKey)).data.data + // 테이블 배열을 1차원으로 정렬해준다. + response.forEach(item => this.tableList.push(item)) + // 테이블 배열을 2차원으로 정렬한다. + // this.tableList.push(response) + } } }, -- GitLab