首页 > 解决方案 > Axios 删除不起作用,它在 chorme 的网络选项卡中显示待处理状态

问题描述

我正在使用 axios Delete 方法删除我的记录。当我发送请求时,它没有返回任何响应。我在 chrome 的 networktab 中看到,API 状态为挂起状态。我正在使用 Redux 和 React。下面是我的代码

我在 Action.js 中导入 service.js 文件

   Action.js file
    const delete = formData => {
      return async dispatch => {
      const data = deleteservice.deleteRetail(formData)
      .then({
         console.log(response)
      }).catch(error => {
        console.log(error);
       })
      }
   }

   service.js
   export const deleteRetail = (formData) => {
   return axios({
   method: 'DELETE,
   URL : myURL,
   headers: {
     'content-type' : 'application/json'
   },
   data : { 
    userID: 'test',
    userName : 'test'

    }
   })
  }

这是我的代码,当我调用这个 delete url 时,状态在网络中显示为待处理。没有得到任何回应。请建议我解决方案

标签: reactjsreact-reduxaxios

解决方案


推荐阅读