programing

'in' 연산자를 사용하여 정의되지 않은 'X'를 검색할 수 없습니다.

prostudy 2022. 8. 24. 23:42
반응형

'in' 연산자를 사용하여 정의되지 않은 'X'를 검색할 수 없습니다.

Uncaughed TypeError: 정의되지 않은 'USER'를 검색하기 위해 'in' 연산자를 사용할 수 없습니다. 이 줄을 이해할 수 없습니다.use 'in' operator to search for 'USERS'그리고 또 왜undefined?

이 오류를 이해할 수 없습니다.설명해 주세요.

My Vuex:

 export default new Vuex.Store({
  state: {
    users: []
  },

  actions: {
    GET_USERS_FROM_API({commit})  {
      return axios('http://localhost:3000/users', {
        method: GET
      })
      .then((response) => {
        commit('SET_USERS_TO_VUEX', response.data)
      })
    }
    
  },
  mutations: {
    SET_USERS_TO_VUEX: (state, users) => {
      state.users = users
    }
  },
  getters: {
        USERS(state) {
      return state.users
    }
},

  modules: {

}

제 대본은 다음과 같습니다.

import {mapActions, mapGetters} from 'vuex'
export default {
  name: 'Home',
  components: {
  },
  data() {

  },

  computed: {
    ...mapGetters([
      'USERS'
    ])

  },

  methods: {
    ...mapActions([
      'GET_USERS_FROM_API'
    ])
  },

  mounted() {
    this.GET_USERS_FROM_API()
  }
}

</script>

내가 잘못 짚었나 봐axios내 응답vuex? 저는요?defined사용자 상태.제 생각에 제가 실수를 한 것 같아요.axios어떻게 고쳐야 할지 모르겠어요.

구문 오류, GET 메서드에 따옴표를 붙이는 것을 잊어버리고 악리 Import도 잊었습니다.

언급URL : https://stackoverflow.com/questions/65665578/cannot-use-in-operator-to-search-for-x-in-undefined

반응형