Node.js 正在将nodeJS API提取到ReactJS

Node.js 正在将nodeJS API提取到ReactJS,node.js,reactjs,api,fetch,fetch-api,Node.js,Reactjs,Api,Fetch,Fetch Api,有人知道如何从NodeJS获取(我不知道它叫什么)API函数到ReactJS吗?我已经试过了,但还是不断出错: 请看一下我的代码: 在ReactJS中删除 onDelete=async(Obj,用户名)=>{ //this.props.deleteUser(idx) 等待取回(“http://localhost:3001/del/“+用户名{ 方法:“删除”, 标题:{ 接受:'application/json', “内容类型”:“应用程序/json” }, 正文:JSON.stringif

有人知道如何从NodeJS获取(我不知道它叫什么)API函数到ReactJS吗?我已经试过了,但还是不断出错:

请看一下我的代码:

在ReactJS中删除

onDelete=async(Obj,用户名)=>{
//this.props.deleteUser(idx)
等待取回(“http://localhost:3001/del/“+用户名{
方法:“删除”,
标题:{
接受:'application/json',
“内容类型”:“应用程序/json”
},
正文:JSON.stringify(Obj)
})
.then(response=>response.text())
.then(res=>console.log(res))
.catch(err=>console.log(“err:,err))

}
如果您等待
获取
,则不需要对其使用promise方法,因为这就是
等待