javascript - How to prevent Axios from encoding my request parameters? -


i'm trying pass in api key through url parameters in request.

however, notice axios encodes characters in api key when sending request. causes api reject request couldn't recognise key.

how can prevent axios encoding parameters?

you can use custom param serializer follows:

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

paramsserializer can set @ instance level:

var instance = axios.create({ paramsserializer: function(params) { /* ... */ } }) 

or @ global level:

axios.defaults.paramsserializer = function(params) { /* ... */ }; 

another option directly add api key url:

axios.get('https://foobar.com/api?api_key=' + key); 

you can add additional parameters using `params' config option:

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

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -