Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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
Express FormData发布在API上,客户端仍然得到;网络错误“;在axios中上载文件时_Express_React Native_Axios_Expo_Multer - Fatal编程技术网

Express FormData发布在API上,客户端仍然得到;网络错误“;在axios中上载文件时

Express FormData发布在API上,客户端仍然得到;网络错误“;在axios中上载文件时,express,react-native,axios,expo,multer,Express,React Native,Axios,Expo,Multer,我正在尝试将图像文件上载到使用multer文件的Express API。 邮递员工作正常。Axios发布数据,但发送网络错误 -createError中的node_modules/axios/lib/core/createError.js:16:24 -handleError中的node_modules/axios/lib/adapters/xhr.js:87:25 - ... 9个来自框架内部的堆栈框架 获取并给出错误 handleChange(value) { this.setSta

我正在尝试将图像文件上载到使用multer文件的Express API。 邮递员工作正常。Axios发布数据,但发送网络错误 -createError中的node_modules/axios/lib/core/createError.js:16:24 -handleError中的node_modules/axios/lib/adapters/xhr.js:87:25 - ... 9个来自框架内部的堆栈框架

获取并给出错误

handleChange(value) {
    this.setState({value});
}

async handleSubmit() {
    const date = this.state.chosenDate
    const value = this._form.getValue();
    var imageName = this.state.imageData.split('/').pop(-1)
    var image = {
        uri : this.state.imageData,
        type : 'image/jpeg' ,
        name : imageName
    }
    const body = { ...value , date : date, image : image}

    var formData  = new FormData();

    for(var name in body) {
        formData.append (name, body[name]);
    }

    console.log(formData)
    const url = IP + '/dummy'



    axios({
        method: 'post',
        url: url,
        data: formData,
        config: { headers: {'Content-Type': 'multipart/form-data' }}
        })
        .then(function (response) {
            //handle success
            console.log(response);
        })
        .catch(function (response) {
            //handle error
            console.log(response);
        });


}

我用的是Expo的React Native你找到解决方案了吗?我用的是Expo的React Native你找到解决方案了吗?