axios的post請求


關於axios的post請求主要講三點:

1、post請求和get請求的區別:

  get把參數包含在URL中,post通過request body傳遞參數

  在傳參時,get使用params,post使用data

2、請求頭:headers

  默認的請求頭:Content-Type:application/x-www-form-urlencoded

  后端限制傳遞的必須為json數據時的請求頭:Content-Type:application/json

  詳細了解見博客

3、http協議的Form Data 和 Request Payload

  Request Payload:請求頭部為 Content-Type: application/json,並且請求正文是一個 json 格式的字符串

  

  Form Data:請求頭部的 Content-Type: application/x-www-form-urlencoded,並且請求正文是類似 get 請求 url 的請求參數

   

 

   qs.stringify()用於將json類型的數據轉換為URL請求參數的形式

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM