(转)如何防止Axios对我的请求参数进行编码?


https://stackoverflow.com/questions/39116731/how-to-prevent-axios-from-encoding-my-request-parameters

axios.get('https://foobar.com/api', {
  paramsSerializer: function(params) {
    var result = '';
    // Build the query string 
    return result;
  }
});

或者全局设置

var instance = axios.create({ paramsSerializer: function(params) { /* ... */ } })
axios.defaults.paramsSerializer = function(params) { /* ... */ };

或者把key直接加在url上

axios.get('https://foobar.com/api?api_key=' + key);
axios.get('https://foobar.com/api?api_key=' + key, {
  params: {
    foo: 'bar'
  }
});