簡體   English   中英

如何解決 React Native Android Axios 網絡錯誤?

[英]How to resolve React Native Android Axios Network Error?

我正在使用 Axios 發布請求進行 API 調用。 它在 iOS 上運行良好,但對於 Android,它顯示為Network Error 400

當我嘗試使用如下所示的encodeURIComponent編碼 URL 時,API 成功,狀態為 200。

return await axios.post(encodeURIComponent(url),JSON.stringify(data), config)
.then(({ data }) => {
  return { success: 1, data };
})
.catch(error => {
  console.log('error', error)
  return { success: 0, error: error.message };
});

因為,關於這個問題的細節很少。 我會說確保設置了Content-Type header。 在 android 上始終需要它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM