mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-26 10:15:40 +01:00
Rename http client factory
This commit is contained in:
parent
df2407c46c
commit
c02af5aab9
@ -1,24 +1,24 @@
|
||||
import axios from "axios"
|
||||
|
||||
export const apiFactory = (endpoint = 'api') => {
|
||||
export const httpClientFactory = (endpoint = 'api') => {
|
||||
let baseURL
|
||||
|
||||
if (endpoint === 'web') {
|
||||
baseURL = '/'
|
||||
} else {
|
||||
baseURL = '/api'
|
||||
baseURL = '/api/v1'
|
||||
}
|
||||
|
||||
const apiClient = axios.create({
|
||||
const httpClient = axios.create({
|
||||
baseURL,
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/json' },
|
||||
withCredentials: true,
|
||||
})
|
||||
|
||||
// see https://github.com/fsgreco/vue3-laravel-api/blob/main/src/api/middlewareCSRF.js
|
||||
//apiClient.interceptors.request.use( middlewareCSRF, err => Promise.reject(err))
|
||||
//httpClient.interceptors.request.use( middlewareCSRF, err => Promise.reject(err))
|
||||
|
||||
apiClient.interceptors.response.use(
|
||||
httpClient.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
@ -35,5 +35,5 @@ export const apiFactory = (endpoint = 'api') => {
|
||||
}
|
||||
)
|
||||
|
||||
return apiClient
|
||||
return httpClient
|
||||
}
|
6
resources/js_vue3/services/systemService.js
vendored
6
resources/js_vue3/services/systemService.js
vendored
@ -1,6 +1,6 @@
|
||||
import { apiFactory } from '@/services/apiFactory'
|
||||
import { httpClientFactory } from '@/services/httpClientFactory'
|
||||
|
||||
const web = apiFactory('web')
|
||||
const webClient = httpClientFactory('web')
|
||||
|
||||
export default {
|
||||
/**
|
||||
@ -8,7 +8,7 @@ export default {
|
||||
* @returns
|
||||
*/
|
||||
getSystemInfos() {
|
||||
return web.get('infos')
|
||||
return webClient.get('infos')
|
||||
},
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user