Created
May 20, 2020 05:08
-
-
Save gatherKnowledge/c8021f8ee4c0cbb0606af530bd1debed to your computer and use it in GitHub Desktop.
My Axios module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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