本文主要是介绍React Native的Android端fetch的网络请求FormData请求错误:TypeError:Network request failed,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
// formdataconst formData = new FormData();formData.append("code", appUserCode);formData.append("wallet", appName);// const formDataStr = 'code=' + appUserCode + '&wallet=' + appName;// 参数形式//const _body = `code=${appUserCode}&wallet=${appName}`;// json JSON.stringify(data)// const jsonData = {// code: appUserCode,// wallet: appName// };var t = {method: 'POST',headers: {//'Content-Type':'application/x-www-form-urlencoded' // ios or other deal.'content-type': 'multipart/form-data' // android special deal method.},body: formData}, n = globalPostUrl, result;console.log("AAA-begin bind user:" + encodeCiyu);await fetch(n, t).then(e => {return e.text();}).then(e => {result = e;}).then(e => {}).catch((error) => {console.error("AAA-报错: " + error);});console.log("AAA-goood:" + result);
};
安卓的请求数据需要添加:'content-type': 'multipart/form-data' // android special deal method.
这篇关于React Native的Android端fetch的网络请求FormData请求错误:TypeError:Network request failed的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!