@jakguru/vueprint / @jakguru/vueprint/services/api / ApiService
Class: ApiService
@jakguru/vueprint/services/api.ApiService
The API Service is a simple instance of Axios which has been pre-configured to include a bearer
token provided from the Local Storage service.
Remarks
Accessing the API Service
The API Service is both injectable and accessible from the global Vue
instance:
<script lang="ts">
import { defineComponent, inject } from 'vue'
import type { ApiService } from '@jakguru/vueprint'
export default defineComponent({
setup() {
const api = inject<ApiService>('api')
return {}
}
mounted() {
const api: ApiService = this.config.globalProperties.$api
}
})
</script>
Using the API Service
For more information, please see the Axios API Documentation
Hierarchy
↳
ApiService
Constructors
constructor
• new ApiService(config?
): ApiService
Parameters
Name | Type |
---|---|
config? | AxiosRequestConfig <any > |
Returns
Overrides
Axios.constructor
Defined in
Properties
defaults
• defaults: AxiosDefaults
<any
>
Overrides
Axios.defaults
Defined in
interceptors
• interceptors: Object
Type declaration
Name | Type |
---|---|
request | AxiosInterceptorManager <InternalAxiosRequestConfig <any >> |
response | AxiosInterceptorManager <AxiosResponse <any , any >> |
request: AxiosInterceptorManager
<InternalAxiosRequestConfig
<any
>>
-
response: AxiosInterceptorManager
<AxiosResponse
<any
, any
>>
-
Overrides
Axios.interceptors
Defined in
Methods
delete
▸ delete<T
, R
, D
>(url
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.delete
Defined in
get
▸ get<T
, R
, D
>(url
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.get
Defined in
getUri
▸ getUri(config?
): string
Parameters
Name | Type |
---|---|
config? | AxiosRequestConfig <any > |
Returns
string
Overrides
Axios.getUri
Defined in
head
▸ head<T
, R
, D
>(url
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.head
Defined in
options
▸ options<T
, R
, D
>(url
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.options
Defined in
patch
▸ patch<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.patch
Defined in
patchForm
▸ patchForm<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.patchForm
Defined in
post
▸ post<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.post
Defined in
postForm
▸ postForm<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.postForm
Defined in
put
▸ put<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.put
Defined in
putForm
▸ putForm<T
, R
, D
>(url
, data?
, config?
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
url | string |
data? | D |
config? | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.putForm
Defined in
request
▸ request<T
, R
, D
>(config
): Promise
<R
>
Type parameters
Name | Type |
---|---|
T | any |
R | AxiosResponse <T , any > |
D | any |
Parameters
Name | Type |
---|---|
config | AxiosRequestConfig <D > |
Returns
Promise
<R
>
Overrides
Axios.request