• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

axios.get(...) 에서 에러가 나는데 검색해도 마땅히 못 찾겠어요

23.04.07 16:25 작성 23.04.07 16:45 수정 조회수 397

2

 "dependencies": {
    "axios": "^1.3.5",
    "core-js": "^3.8.3",
    "vue": "^3.2.13",
    "vue-router": "^4.0.3",
    "vuex": "^4.0.0"
  },

===================================================
import axios from 'axios'
export default {
  data(){
    return {
      users :[],
    }
  },
  created : {
    axios.get('https://api.hnpwa.com/v0/news/1.json')
    .then(function(response){
      console.log(response);
    })
    .catch(function(error){
    })
  }
}

111.png

Module build failed (from ./node_modules/babel-loader/lib/index.js):

SyntaxError: C:\Users\pmgk\Desktop\vuetest\vue_news\src\views\NewsView.vue: Unexpected token, expected "," (10:9)

 //////////////////////////////////////////////////

https://minemanemo.tistory.com/99

위 링크를 통해 babel-eslint 패키지를 설치하고 진행하면

에러 문구만 조금 달라지고 변함은 없네요 ㅠ.

검색해 도 마땅히 나오지 않아 해결을 못 하고 있습니다. 조언 부탁드립니다..

답변 1

답변을 작성해보세요.

1

박진영님의 프로필

박진영

2023.04.08

create : {

...

}

create() {

}

함수로 해주셔야 할 것 같습니다

Won Ders님의 프로필

Won Ders

질문자

2023.04.08

감사합니다 ㅠㅠ 제 실수엿네요.

네 진영님이 잘 답변해 주셨네요. 감사합니다 진영님 :)