亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在調試模式下,圖像和視頻未使用 axios 上傳到服務器

在調試模式下,圖像和視頻未使用 axios 上傳到服務器

慕標琳琳 2023-06-09 15:26:10
我正在使用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,          duration: Snackbar.LENGTH_SHORT,        });      });  };//add pic code export const updatePic = (data, token, rsl, 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);      });  };};
查看完整描述

1 回答

?
九州編程

TA貢獻1785條經驗 獲得超4個贊

我已經通過評論這一行解決了它 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));

     }

   });


查看完整回答
反對 回復 2023-06-09
  • 1 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號