Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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 在Firebase上获取错误-FirebaseError:无效段(用户//购物车)。路径中不能包含/_Javascript_Firebase_Google Cloud Firestore - Fatal编程技术网

Javascript 在Firebase上获取错误-FirebaseError:无效段(用户//购物车)。路径中不能包含/

Javascript 在Firebase上获取错误-FirebaseError:无效段(用户//购物车)。路径中不能包含/,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,在cart.component.ts中编码 this.cart.getCart().subscribe(cs => { this.shoppingCart = cs.map( x =>{ return{ id: x.payload.doc.id, ...x.payload.doc.data() as {} } }) } getCart(){

在cart.component.ts中编码

this.cart.getCart().subscribe(cs => 
      {
        this.shoppingCart = cs.map( x =>{
        return{
          id: x.payload.doc.id,
          ...x.payload.doc.data() as {}
          }
        })
      }
getCart(){
    return this.fs.collection(`users/${this.as.userId}/cart`).snapshotChanges()
  }
购物车.service.ts中的代码

this.cart.getCart().subscribe(cs => 
      {
        this.shoppingCart = cs.map( x =>{
        return{
          id: x.payload.doc.id,
          ...x.payload.doc.data() as {}
          }
        })
      }
getCart(){
    return this.fs.collection(`users/${this.as.userId}/cart`).snapshotChanges()
  }

我在这里看到的唯一可能性是
this.as.userId
为空。确保该值不为空,这将解决问题。因为它是空的,
getCart()
函数试图查询集合
用户//购物车
,但是
用户/
/cart
部分之间应该有一个用户id