Axios发送网络请求

531 阅读1分钟

Axios发送网络请求

1. Axios发送get请求

axios.get("//localhost:3000/api/");

axios.get(`//localhost:3000/api/?id={id}`);

axios.get("//localhost:3000/api/",{ params: params });

2. Axios发送post请求

axios.post("//localhost:3000/api/", data);

3. Axios自定义header

axios.get("//localhost:3000/api/",{
  withCredentials: true
});

axios.post("//localhost:3000/api/",{
  withCredentials: true,
  headers: { "Content-Type": "application/json" }
});