【问题标题】:Axios POST resulting in NULLAxios POST 导致 NULL
【发布时间】:2020-05-17 18:30:30
【问题描述】:

这是我的烧瓶代码,

@app.route("/", methods=['GET','POST'])
@cross_origin()
def helloWorld():
    data = request.json
    return jsonify(data)

我在 Vue 中使用 axios 将数据发布到 localhost:5000。我可以发布它,但在烧瓶中它显示为空。

axios.post('http://127.0.0.1:5000/', {
    firstName: 'Fred',
    lastName: 'Flintstone'
      })
      .then(function (response) {
        console.log(response.data);
      })
      .catch(function (error) {
        console.log(error);
      });

当我在 Vue 中这样做时,

axios
      .get('http://127.0.0.1:5000')
      .then(response => console.log(response))
      .catch(error => console.log(error))

我得到正确的输出,即发布的数据,但在烧瓶中我得到 null 作为响应。 有人知道为什么会这样吗?

【问题讨论】:

标签: api vue.js post flask axios


【解决方案1】:

从帖子地址中删除最后一个/

【讨论】:

    猜你喜欢
    • 2018-05-06
    • 2013-03-29
    • 2018-01-07
    • 1970-01-01
    • 2019-11-29
    • 2019-04-26
    • 1970-01-01
    • 2020-07-07
    • 2023-01-07
    相关资源
    最近更新 更多