小编ani*_*mar的帖子

函数 CollectionReference.add() 要求它的第一个参数是对象类型,但它是: undefined

我想将图像存储在 firebase 存储中并在 firestore 中传递其 URL 引用。因此,我可以在存储中上传图像,但无法在云 Firestore 中传递图像 URL 引用。

import React , {Component} from 'react';
import fire from './../fire'
import Uploadimg from './Uploadimg'

class Adproduct extends Component{

  geturl = (imurl) =>{
      this.setState({
          img:imurl
        });
  }
  submit = e =>{
      e.preventDefault()
      var db= fire.firestore();

      db.settings({
        timestampsInSnapshots: true
           });

      db.collection('newproducts').add(this.State)
      .then(res =>{
          console.log(res.id)

          this.props.submit()
      })
      .catch(err =>{
          console.log('something went wrong',err)
      })
  }
  takedata = e =>{
      this.setState({
          [e.target.name]: e.target.value 
      });
  }

  constructor(props){
      super(props);
      this.state ={
          name:'',
          productdetails:'',
          size:'',

      }
  } …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs google-cloud-firestore

4
推荐指数
1
解决办法
7158
查看次数

标签 统计

firebase ×1

google-cloud-firestore ×1

reactjs ×1