axios發送OPTIONS請求
因為發送的請求不是simple request
,所以瀏覽器會發送一個OPTIONS
請求詢問服務器是否可以請求,這樣每次請求都會發送兩次請求,解決的辦法是簡化請求。
simple request
- get、post、head 請求類型
- 不要設置列表之外的header(如: user-agent)
-
Content-Type 只能是:
- application/x-www-from-urlencoded
- multipart/from-data
- text/plain
不設置Content-Type
默認的屬性是application/json