programing

내부 서버 오류: /삭제 요청 URL 끝에 정의되지 않음

projobs 2023. 6. 23. 23:44
반응형

내부 서버 오류: /삭제 요청 URL 끝에 정의되지 않음

점점 ~하다undefined/URL 끝에 있고 원인을 파악할 수 없는 것 같습니다.
vuejs, vuex 및 bootstrap-vue 사용

HTML:

     <template slot="time" slot-scope="row">
        <b-button @click="deleteTime(row.value.id)">
          Delete
        </b-button>
      </template>

`

방법: '

    deleteTime (id) {
      this.$store.dispatch('deleteTime', id)
    }

`

Action.vue: '

async deleteTime ({ commit, state }, time) {
    commit('SET_LOADING', true)
    const id = state.route.params.pageId
    await api.deleteTime(id, time)
    commit('SET_LOADING', false)
  }

`

api.js:

`

let deleteTime = '/api/apps/:id/content/time/?id=:timeId'

    async deleteTime (id, time) {
        const url = deleteTime.replace(':id', id).replace(':timeId', time)
        return http.delete(url)
      }

`

알겠습니다http://127.0.0.0:8000/api/apps/1/content/time/?id=10undefined/이 정의되지 않은 것이 어디서 온 것인지는 확실하지 않습니다.

어떤 도움이라도 주시면 감사하겠습니다.

업데이트:

enter image description here

http.delete 모듈: '

import axios from 'axios'

const http = axios.create({
  xsrfCookieName: 'csrftoken',
  xsrfHeaderName: 'X-CSRFToken'
})

export default {
  async delete (url, id) {
    const response = await http.delete(`${url}${id}/`)
    return response
  }
}

`

감사해요.

쿼리 매개 변수가 포함된 전체 URL을 공리에 전달하고 있습니다.delete제 생각에 당신은 그것을 제거하기만 하면 될 것 같습니다.id인수:

export default {
  async delete (url) {
    const response = await http.delete(`${url}`)
    return response
  }
}

간단히 제거합니다.id논쟁은 이유입니다.${id}/로 평가함.undefined/당신은 통과하지 못합니다.id매개 변수입니다.

가장 쉬운 방법:

간단히export http

언급URL : https://stackoverflow.com/questions/55605394/internal-server-error-undefined-at-the-end-of-url-for-delete-request

반응형