【问题标题】:Uncaught (in promise) Error: Request failed with status code 405 POST AXIOS未捕获(承诺中)错误:请求失败,状态码为 405 POST AXIOS
【发布时间】:2020-07-30 09:49:47
【问题描述】:

我正在尝试在我的数据库中发布数据,但每次我尝试这样做时都会收到 405 错误。 python也有一个错误说我正在提交一个空列表。请指出我正确的方向来解决这个问题。

const axios = require('axios')
       let URL = 'http://127.0.0.1:5000/Walls/saveComments'
       let HEADERS = {'Content-Type': 'text/plain;charset=utf-8'}

      axios.post(URL, HEADERS, {
          'post': post,
          'time': time
        })
        .then(function (response) {
          console.log(response);
        })

       // Axios Call to Save A Post in Backend
     }

【问题讨论】:

  • 看起来您将参数传递给 axios.post 的顺序不正确。可以试试here吗?
  • 以上有帮助吗?

标签: reactjs axios


【解决方案1】:

应该是,,,

const axios = require('axios')
       let URL = 'http://127.0.0.1:5000/Walls/saveComments'
       let HEADERS = {'Content-Type': 'text/plain;charset=utf-8'}
const data = 'your data to post'

      axios.post(URL, data, {
           'headers': HEADERS,
          'post': post,
          'time': time
        })
        .then(function (response) {
          console.log(response);
        })

       // Axios Call to Save A Post in Backend
     }

【讨论】:

    【解决方案2】:

    发布请求的正确顺序是 axios.post(url[, data[, config]]) .这可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-17
      • 2018-08-09
      • 1970-01-01
      • 2019-08-03
      • 2020-12-01
      • 2020-11-27
      • 2019-08-15
      • 1970-01-01
      相关资源
      最近更新 更多