【发布时间】:2019-02-05 05:52:09
【问题描述】:
我正在使用react js,我想发布文本并返回文本。
谁能帮助我发布文本和接收文本?我用过了
content type text/plain 但这没有帮助。
有什么办法吗?
const options = {
method: "POST",
headers: {
"Content-Type": "text/plain"
},
body: this.state.url
}
fetch("http://localhost:3000/messages", options)
.then(response => response)
.then(data => {
console.log(data)
this.setState({
code: data
});
});
这是我尝试从 api 获取文本值的内容
我收到一个错误
Uncaught promise typeError 获取失败
【问题讨论】:
-
发到哪里?从什么获得?你想做什么?
-
请在您的问题中更具体。
-
阅读 github.com/axios/axios 以进行 api 调用
标签: javascript node.js reactjs