Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 财产';捕捉';不存在于类型';承诺式<;无效>';在爱奥尼亚_Javascript_Firebase_Firebase Realtime Database_Try Catch - Fatal编程技术网

Javascript 财产';捕捉';不存在于类型';承诺式<;无效>';在爱奥尼亚

Javascript 财产';捕捉';不存在于类型';承诺式<;无效>';在爱奥尼亚,javascript,firebase,firebase-realtime-database,try-catch,Javascript,Firebase,Firebase Realtime Database,Try Catch,嗨,我有下面的方法,我正在尝试使用 sendrequest(req: connreq) { var promise = new Promise((resolve, reject) => { this.firereq.child(req.recipient).push({ sender: req.sender }).then(() => { resolve({ success: true }); }).catch((error) => {

嗨,我有下面的方法,我正在尝试使用

sendrequest(req: connreq) {
var promise = new Promise((resolve, reject) => {
  this.firereq.child(req.recipient).push({
  sender: req.sender
  }).then(() => {
    resolve({ success: true });
    }).catch((error) => {
      resolve(error);
})
})
return promise;  
}
但是我的VisualStudio代码给了我以下错误

Property 'catch' does not exist on type 'PromiseLike<void>'
类型“PromiseLike”上不存在属性“catch”
我正在使用ionic来编译这个程序,我不确定如何纠正这个方法。我的教程在爱奥尼亚3中,所以它可能是旧的,我不知道如何修改它以适应新版本。

避免!要将类似承诺的东西转换为真正的承诺,只需使用:

sendrequest(req: connreq) {
  return Promise.resolve(this.firereq.child(req.recipient).push({
    sender: req.sender
  }));
}