Skip to content

Instantly share code, notes, and snippets.

@kaelfeitosa
Last active April 14, 2018 01:08
Show Gist options
  • Save kaelfeitosa/3058cee098964a218296e044fca1c208 to your computer and use it in GitHub Desktop.
Save kaelfeitosa/3058cee098964a218296e044fca1c208 to your computer and use it in GitHub Desktop.
// singleton export
const api = axios.create({
bar: 'foo'
});
export default api;
// build export
const api = () => {
return axios.create({
bar: 'foo'
});
}
export default api;
// build singleton export
let _api;
const api = () => {
return _api ? _api : _api = axios.create({
bar: 'foo'
});
}
export default api;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment