我正在使用 axios 将数据发布到我的本地服务器。
_handleBarCodeRead = data => {
axios.post('192.168.0.100/getitem', {
id: data.data,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
};
数据在事件中发布
<BarCodeScanner
torchMode="off"
onBarCodeRead={this._handleBarCodeRead}
/>
最佳答案
尝试通过添加前缀(使用 http 或 https)'http://使 URL 成为相对
。('/getitem')
或正确绝对 URL 192.168.0.100/getitem'
_handleBarCodeRead = data => {
axios.post('http://192.168.0.100/getitem', {
id: data.data,
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
};
关于javascript - react native 'unexpected url'错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49031641/