![](/img/trans.png)
[英]Axios POST request: Content-type is set, but inside spring it's empty
[英]How to set basic auth, content-type and data to send in axios post request?
我是 React Native 的初學者,我正在嘗試使用 axios 將數據發送到 IBM 語音到文本轉換 Api。 我在 Postman 中收到響應,但無法在 axios 請求中設置我的數據。 請求需要基本身份驗證、內容類型和文件(數據)。 如何在 axios 請求中設置所有這些? 我得到 415 的狀態代碼這是代碼 Picture 。
axios .post( IBMURL, { withCredentials: true, headers: { 'Content-Type': 'audio/mp3', }, }, { auth: { username: 'apikey', password: ApiPassword, }, }, ) .then((response) => { console.log('Reponse', response.data); }) .catch((e) => console.log(e));
axios.post
在url
之后需要一個正文:
axios.post(url, body, options);
傳遞null
或空對象應該可以解決它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.