我制作了一些小应用程序,可以读取条形码并通过API发送数据。
示例:
handleBarCodeScanned = ({ type, data }) => {
alert(`Bar code with type ${type} and data ${data} has been scanned! and the phone is ${this.state.maci`);
var BarCodeScannedInApp = 'http://localhost:50474/api/ScanPart?PartBarCode=' + data + "&StationName=" + this.state.maci;
fetch(BarCodeScannedInApp)
.then(response => response.json())
.catch(error => console.log('parsing failed', error))
};
当代码尝试执行Fetch时,会引发异常“解析失败[TypeError:网络请求失败]”
app.json:
{
"expo": {
"name": "my-test-scan",
"slug": "my-test-scan",
"privacy": "public",
"sdkVersion": "33.0.0",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
有什么建议吗?