TypeError:网络请求无法响应本机

时间:2019-12-08 14:34:37

标签: reactjs azure react-native ocr

我正在获取请求,并且正在执行此操作,我收到此错误:

  

[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)

});
  };

0 个答案:

没有答案