我正在获取请求,并且正在执行此操作,我收到此错误:
[TypeError:网络请求失败]
顺便说一句,我正在向azure ocr视觉网站提出获取请求
代码:
selectImage() {
ImagePicker.showImagePicker(options, (response) => {
// ...
const source = { uri: response.uri };
this.setState({ imageSource: source });
this.setState({
loading: true
})
console.log(response.type)
// You can also display the image using data:
this.extractText(response.uri, response.type);
}
});
}
extractText = async (imageSource, imageType) => {
// ...
const data = new FormData();
data.append('photo', {
uri: imageSource,
type: imageType, // or photo.type
name: 'testPhotoName'
});
fetch(uriBase,
{
method: 'POST',
headers:
{
'Content-Type': 'multipart/form-data',
'Ocp-Apim-Subscription-Key': subscriptionKey,
},
body: data,
}).then((response) => response.json()).then((data) =>
{
}).catch((error) =>
{
console.log(error)
});
};