(转)如何防止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'
  }
});

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM