Skip to content

Commit

Permalink
feat: create Axios instance
Browse files Browse the repository at this point in the history
  • Loading branch information
nabilasherif committed Aug 28, 2024
1 parent 6bbdb15 commit 42fefb0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"@mdi/font": "7.4.47",
"axios": "^1.7.5",
"core-js": "^3.37.1",
"roboto-fontface": "*",
"vue": "^3.4.31",
Expand Down
73 changes: 73 additions & 0 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions client/src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import axios, { AxiosInstance } from 'axios'
import axiosClient from 'axios'

export const AuthClient: AxiosInstance = axios.create({
const accessToken = localStorage.getItem('TESTTRACKER_ACCESS_TOKEN')
export const axios = axiosClient.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
headers: {
'Content-Type': 'application/json',
Authorization: localStorage.getItem('token'),
Authorization: `Bearer ${accessToken}`,
},
})

export const BaseClient: AxiosInstance = axios.create({
baseURL: window.env.SERVER_DOMAIN_NAME_API,
timeout: 1000,
})

0 comments on commit 42fefb0

Please sign in to comment.