Superagent 回调中的调用函数 - React

Call function in callback of Superagent - React

我想在请求结束时(当我得到响应时)使用 Superagent 调用一个函数。

request.post('/TextUpload')
.send({title:this.state.title1})
.end( function(res){
   console.log(res);
   this.myFunction();
})

但我得到错误:这是空的或未定义的。

MyFunction() 已在构造函数中声明和绑定。 我不能直接在回调中编写函数的代码,因为我这样做 this.props.refresh(true); (它向父级发送数据)

I get the error : this is null or undefined.?

这应该work.Use箭头函数来获得词法作用域绑定

.end((res)=>{
   console.log(res);
   this.myFunction();
})