gpt4 book ai didi

javascript - 如何在 JS 代码中使用 Flask.Response?

转载 作者:行者123 更新时间:2023-12-03 01:13:52 25 4
gpt4 key购买 nike

我已经尝试了一段时间了,但我未能在前端获得后端返回的值。

这是我的代码:

def add_New_Form():
resp = Response("something") #Note that the response value is a string
return resp

我希望能够在我的前端使用它(我正在使用 Vue)。我无法 jsonify resp 因为 Response 不可 jsonify。我试过:

var name = this.$http.post(*My request here*)

但这并没有像我预期的那样工作。

提前致谢。

最佳答案

你永远不会处理响应。当您使用 this.$http (可能是 vue-resource)时,您的请求会返回一个 Promise,然后您可以从中链接:

this.$http.post(*My request here*)
.then( response => {
console.log(response.data) // it's your string
})

关于javascript - 如何在 JS 代码中使用 Flask.Response?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52107234/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com