-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(axios): create custom axios instance
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
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
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 |