Skip to content

Commit

Permalink
feat(axios): create custom axios instance
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Jul 9, 2019
1 parent 56284aa commit 46b6ef9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios'

// axios HTTP client
// https://github.com/axios/axios
// create an instance using the config defaults provided by the library
const instance = axios.create({
// up to 60s timeout
timeout: 60000
})
// always JSON for request with body data
;[ 'post', 'patch', 'put' ].forEach(method => {
instance.defaults.headers[method]['Content-Type'] = 'application/json'
})

export default instance

0 comments on commit 46b6ef9

Please sign in to comment.