反应原生,失败在ios中发布与base64中的图像作为字符串

时间:2018-10-14 19:27:04

标签: react-native post base64 fetch

我正在尝试在base64中发送数据以及带有fetch的后处理请求的两个图像,在android中工作正常,但最后请求未完成,它进行了发送,但从未到达服务器,而且我从未有答案。

它仅在ios中发生,有解决方案吗?也许是因为图像太长?

async addClients(datas, add, image) {
    var data = {
        user: datas.user,
        pass: datas.pasw,
        apikey: apikey
    }
    const file = image
    var form = new FormData();
    form.append('apikey', data.apikey);
    form.append('user', data.user);
    form.append('passw', data.pass);
    form.append('nom_cli', add.nom_cli);
    form.append('rsoc_cli', add.rsoc_cli);
    form.append('pais_cli', add.pais_cli);
    form.append('cif_cli', add.cif_cli);
    form.append('tel1_cli', add.tel1_cli);
    form.append('tel2_cli', add.tel2_cli);
    form.append('pob_cli', add.pob_cli);
    form.append('pro_cli', add.pro_cli);
    form.append('email_cli', add.email_cli);
    form.append('comi_cli', add.comi_cli);
    form.append('dir_cli', add.dir_cli);
    form.append('cp_cli', add.cp_cli);
    form.append('repres_cli', add.repres_cli);
    form.append('file', JSON.stringify(file));
    const query = await fetch(`${URL}/set-user`, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'multipart/form-data'
        },
        body: form
    })
    .then(res => res.json())
    .catch(error => { console.log(error, 'Error') })
    .then(response => response)
    console.log(query, 'response')
    return query

0 个答案:

没有答案