在调试模式下,图像和视频未使用axios上传到服务器

问题描述

我正在使用react-native-image-crop-picker从图库中获取图像,并尝试使用Axios将其上传到服务器上。但是它没有上传到服务器上,当我点击api进行上传时,它开始发送并且永无休止并没有收到来自服务器的响应。但是,当我尝试进行构建并尝试上传然后成功上传并从服务器获取响应时。 这是我的代码

const handleProfilePic = () => {
    const date = new Date();

    const formData = new FormData();
    formData.append('files',{
      uri: image.path,type: image.mime,name: 'image_' + Math.floor(date.getTime() + date.getSeconds() / 2),});
    console.log(formData);
    new Promise((rsl,rej) => {
      setLoading(true);
      updatePic(formData,user.auth,rsl,rej);
    })
      .then((res) => {
        Snackbar.show({
          text: res,duration: Snackbar.LENGTH_SHORT,});
        setLoading(false);
      })
      .catch((errorData) => {
        setLoading(false);
        Snackbar.show({
          text: errorData,});
      });
  };



//add pic code 

export const updatePic = (data,token,rej) => {
  return (dispatch) => {
    axios(`${BASE_URL}/Authentication/addpicture`,{
      method: 'post',data,headers: {
        auth: token,},})
      .then((res) => {
        console.log(res);
        if (res.data.status == true) {
          rsl(res.data.message);
        } else {
          rej(res.data.message);
        }
      })
      .catch((err) => {
        console.log(err);
        rej(err.message);
      });
  };
};

解决方法

我已经通过注释此行解决了它 Open this dir 'android/app/src/debug/java/com/flatApp/ReactNativeFlipper.java'

NetworkingModule.setCustomClientBuilder(
   new NetworkingModule.CustomClientBuilder() {
     @Override
     public void apply(OkHttpClient.Builder builder) {
       // builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
     }
   });