formData 和 qs.stringify()

  1. formData
 this.formData = new FormData();
 that.formData.append('carplate', that.carplate);
 that.formData.append('total', that.total);
 that.formData.append('payway', that.payway);
 Api.post("/api/auth", that.formData).then(response => {
    if (response.code == '200') {
       
    }
});
  1. qs.stringify()
// 安装qs    npm i  qs
// 安装axios     npm i  axios

import Api from '../api.js'
import qs from 'qs'

 Api.get('/api/group/', qs.stringify( this.data ) ).then(response => {
      if (response.code == '200') {
       
      }
   })

  1. 请求头
headers = {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
      'token': localStorage.getItem('token') //缓存的token
    }

你可能感兴趣的:(formData 和 qs.stringify())