Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.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 Can';找不到变量atob React Native+;火基误差_Javascript_Node.js_Reactjs_Firebase_React Native - Fatal编程技术网

Javascript Can';找不到变量atob React Native+;火基误差

Javascript Can';找不到变量atob React Native+;火基误差,javascript,node.js,reactjs,firebase,react-native,Javascript,Node.js,Reactjs,Firebase,React Native,我有一个post屏幕,在那里我可以从相机卷中选择一个图像并键入一个文本,我希望它保存在Firebase中。 这是我在fire.js中的代码 addPost = async({text,localUri}) => { const remoteUri = await this.uploadPhotoAsync(localUri) return new Promise((res,rej) => { this.firestore.collection("p

我有一个post屏幕,在那里我可以从相机卷中选择一个图像并键入一个文本,我希望它保存在
Firebase
中。 这是我在
fire.js中的代码

 addPost = async({text,localUri}) => {
    const remoteUri = await this.uploadPhotoAsync(localUri)

    return new Promise((res,rej) => {
        this.firestore.collection("posts").add({
            text,
            uid: this.uid,
            timestamp:this.timestamp,
            image: remoteUri
        })
        .then(ref => {
            res(ref)
        })
        .catch(error => {
            rej(error)
        })
    })
}

uploadPhotoAsync = async uri => {
    const path =  `photos/${this.uid}/${Date.now()}.jpg`

    return new Promise(async (res,rej) => {
        const response = await fetch(uri)
        const file = await response.blob()

        let upload = firebase.storage().ref(path).put(file)

        upload.on(firebase.storage.TaskEvent.STATE_CHANGED,snapshot => {},
        err => {
            rej(err)
        },
        async () => {
            const url = await upload.snapshot.ref.getDownloadURL()
            res(url)
        }
        )
    })
}
这是我的
postscreen.js
屏幕,在这里我得到了一个错误
找不到变量atob

请给我一个解决方案

handlePost = () => {
 Fire.shared.addPost({text:this.state.text.trim(),
  localUri:this.state.image })
   .then(ref => {
    this.setState({text:"",image:undefined})
    this.props.navigation.goBack()
     }).catch(error => {
       alert(error)
     })
   }



 pickImage = async () => {
     let result = await ImagePicker.launchImageLibraryAsync({
       mediaTypes: ImagePicker.MediaTypeOptions.Images,
       allowsEditing:true,
       aspect:[4,3]
     })

 if(!result.cancelled) {
   this.setState({image: result.uri})
 }
}


顺便说一句,我可以看到图像保存在
Firestore
存储中,但我看不到
Firestore
数据库中的文本和照片

这是某些版本的
firebase
中的一个错误

一种解决方法是在
app.js
中导入base64,并在未定义的情况下对其进行定义

import {decode, encode} from 'base-64'

if (!global.btoa) { global.btoa = encode }
if (!global.atob) { global.atob = decode }

你在某处使用了这个
atob
,但在使用之前没有定义它。我不知道,我甚至不知道atob实际上是什么,但错误不在你共享的代码片段中。