我在Android应用程序中进行注册时遇到问题。
static creaUtente(identity, FirstName, LastName, FiscalCode , Email) {
let formdata = new FormData();
formdata.append('Identity', identity);
formdata.append('FirstName', FirstName);
formdata.append('LastName', LastName);
formdata.append('FiscalCode', FiscalCode);
formdata.append('Email', Email);
console.log(Configuration.base_url.rest + Configuration.apiRoutes.signUp)
console.log(formdata)
return new Promise((resolve, reject)=> {
fetch(Configuration.base_url.rest + Configuration.apiRoutes.signUp,{
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formdata
})
.then((response) => response.json())
.then((responseData) => {
if(responseData.Error){
Alert.alert("Errore");
}
global.utente = responseData;
resolve(responseData)
})
.catch((err) => {reject(err)})
})
}
这是我使用的代码,在获取中,我传递了指向我的API的链接(这可以正常工作。这是一个https链接)
但是当我尝试在我的应用程序中注册时,收到此错误:
例如,这是我收到的日志
[['身份', {ProjectName:{用户名:'TNNFRZ77H01G273V',密码:'12345'}}], ['FirstName','Fabrizio'], ['LastName','Tonno'], ['FiscalCode','TNNFRZ77H01G273V'],['Email','Fabrizio.tonno@email.com']]} {[TypeError:网络请求 失败]
我不知道该怎么办:( 你能帮助我吗?
在Chrome中使用调试器:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (whatwg-fetch.js:504)
at XMLHttpRequest.dispatchEvent (event-target.js:172)
at XMLHttpRequest.setReadyState (XMLHttpRequest.js:580)
at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:394)
at XMLHttpRequest.js:507
at RCTDeviceEventEmitter.emit (EventEmitter.js:181)
at MessageQueue.__callFunction (MessageQueue.js:366)
at MessageQueue.js:106
at MessageQueue.__guard (MessageQueue.js:314)
at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:105)
package.json
dependencies": {
"@react-native-community/async-storage": "^1.4.2",
"buffer": "^5.2.1",
"pouchdb-adapter-asyncstorage": "^6.4.1",
"pouchdb-authentication": "^1.1.3",
"pouchdb-find": "^7.0.0",
"pouchdb-react-native": "^6.4.1",
"react": "16.8.3",
"react-native": "0.59.4",
"react-native-ble-manager": "^6.6.2",
"react-native-ble-plx": "^1.0.3",
"react-native-json-tree": "^1.2.0",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-router-flux": "^4.0.6",
"react-native-tab-navigator": "^0.3.4",
"react-native-vector-icons": "^6.4.2"
},
"devDependencies": {
"@babel/core": "7.4.3",
"@babel/runtime": "7.4.3",
"babel-jest": "24.7.1",
"jest": "24.7.1",
"metro-react-native-babel-preset": "0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}