Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.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
Android HostFunction中出现异常:来自JS的格式错误的调用:字段大小不同_Android_React Native_Axios - Fatal编程技术网

Android HostFunction中出现异常:来自JS的格式错误的调用:字段大小不同

Android HostFunction中出现异常:来自JS的格式错误的调用:字段大小不同,android,react-native,axios,Android,React Native,Axios,我正在尝试向后端发送post请求,但应用程序不断抛出此错误: HostFunction中出现异常:来自JS的错误调用:字段大小不同 [46,11,46],[1,0,0],[462], [4652000156969121,假]],1591] 服务器已经过测试,当我从命令行使用curl发送数据时,它确实保存了数据 这是处理请求的函数 handleComment = async ()=>{ const {comment, isAuth} = this.state;

我正在尝试向后端发送post请求,但应用程序不断抛出此错误:

HostFunction中出现异常:来自JS的错误调用:字段大小不同

[46,11,46],[1,0,0],[462], [4652000156969121,假]],1591]

服务器已经过测试,当我从命令行使用curl发送数据时,它确实保存了数据

这是处理请求的函数

handleComment = async ()=>{
        const {comment, isAuth} = this.state;
        const userToken = await AsyncStorage.getItem('userToken');
        const token = "Token "+ userToken;

        if(isAuth!==null&&isAuth===true){
            if(
                comment!==null&&
                comment!==undefined
            ){

                const endpoint ='http://10.0.2.2:8000/api/comments/create/';
                const payload = {
                    comment: comment,
                    post: [this.props.postID]
                };

                axios.post(endpoint, payload, {
                    headers:{
                        'Auuthorization': token
                    }
                })
                    .then(response =>{
                        if(response!==null&&response!==undefined){

                            Alert.alert('Success', 'Your comment was successfully sent.');
                        }else{
                            Alert.alert('Comment send error', 'Your comment could not be sent.');
                        }

                    }).catch(error=>{
                        console.log(error);
                    })

            }else{
                Alert.alert('Comment send error', 'Please write your comment before sending.');
            }
        }else{
            Alert.alert('Authorization error', 'You need to login before sending a comment.');
        }
    }


你试过
post:this.props.postID
?@hongdevelop吗?是的,我试过了,但它总是给我同样的错误