강의

멘토링

커뮤니티

Inflearn コミュニティ Q&A

wonders8080 のプロフィール画像
wonders8080

投稿した質問数

Vue.js 完全ガイド - 実習とリファクタリングで学ぶ実践概念

axiosを利用したAPIコール

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

作成

·

684

·

編集済み

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 패키지를 설치하고 진행하면

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

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

axios

回答 1

1

create : {

...

}

create() {

}

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

Won Ders님의 프로필 이미지
Won Ders
質問者

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

captain님의 프로필 이미지
captain
インストラクター

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

wonders8080 のプロフィール画像
wonders8080

投稿した質問数

質問する