Skip to content

Instantly share code, notes, and snippets.

@gatherKnowledge
Created May 20, 2020 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatherKnowledge/c8021f8ee4c0cbb0606af530bd1debed to your computer and use it in GitHub Desktop.
Save gatherKnowledge/c8021f8ee4c0cbb0606af530bd1debed to your computer and use it in GitHub Desktop.
My Axios module
import axios from "axios";
import qs from 'qs';
export default class Model {
constructor(modelName) {
this.modelName = modelName;
const instance = axios.create({
baseURL: 'http://127.0.0.1/api/',
timeout: 1000,
headers: {'X-Custom-Header': 'foobar'},
params: {
ID: 12345
},
paramsSerializer: function (params) {
return qs.stringify(params, {arrayFormat: 'brackets'})
},
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment