Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Axiso 使用姿势指南 · 评论 #34

Open
ifyour opened this issue Sep 22, 2018 · 3 comments
Open

Axiso 使用姿势指南 · 评论 #34

ifyour opened this issue Sep 22, 2018 · 3 comments

Comments

@ifyour
Copy link
Owner

ifyour commented Sep 22, 2018

https://ifyour.github.io/2018/09/19/Axios-使用姿势指南/

@ifyour
Copy link
Owner Author

ifyour commented Oct 11, 2018

Axios 如何发送 Content-Type 为 multipart/form-data 的数据

let formData = new FormData();
formData.append("appkey", "njssdjtkj");
formData.append("sign", sign);
formData.append("sign_method", "MD5");
formData.append("mobile", "15951971791");
formData.append("engine_no", "070939");
formData.append("plate_type", "02");
formData.append("plate_no", "苏EXW365");

axios({
  method: "post",
  url: "/api/search.do",
  data: formData,
  // data:{appkey: "njssdjtkj",sign:sign,sign_method:"MD5",timestamp:time,mobile:"15951971791",engine_no:"070939",plate_type:"02",plate_no:"苏EXW365"},
  headers: {
    "Content-Type": "multipart/form-data"
  }
}).then(function(res) {
  console.log(res);
});

@ifyour
Copy link
Owner Author

ifyour commented Mar 3, 2019

Content-Type 小节的详细介绍可以参考这篇文章:四种常见的 POST 提交数据方式 @Jerry Qu

@ifyour
Copy link
Owner Author

ifyour commented Mar 5, 2019

Axios 在浏览器端是基于 XMLHttpRequest 的请求。目前有更好的后端传输数据方案,就是 windows.fetch。详细文章可以参考这篇:传统 Ajax 已死,Fetch 永生 @Github/camsong

基于 window.fetch 的封装:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant