Skip to content

@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:

vue

<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

Constructors

constructor

new ApiService(config?): ApiService

Parameters

NameType
config?AxiosRequestConfig<any>

Returns

ApiService

Overrides

Axios.constructor

Defined in

src/services/api.ts:129

Properties

defaults

defaults: AxiosDefaults<any>

Overrides

Axios.defaults

Defined in

src/services/api.ts:130


interceptors

interceptors: Object

Type declaration

NameType
requestAxiosInterceptorManager<InternalAxiosRequestConfig<any>>
responseAxiosInterceptorManager<AxiosResponse<any, any>>

request: AxiosInterceptorManager<InternalAxiosRequestConfig<any>>

-


response: AxiosInterceptorManager<AxiosResponse<any, any>>

-


Overrides

Axios.interceptors

Defined in

src/services/api.ts:131

Methods

delete

delete<T, R, D>(url, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.delete

Defined in

src/services/api.ts:141


get

get<T, R, D>(url, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.get

Defined in

src/services/api.ts:137


getUri

getUri(config?): string

Parameters

NameType
config?AxiosRequestConfig<any>

Returns

string

Overrides

Axios.getUri

Defined in

src/services/api.ts:135


head<T, R, D>(url, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.head

Defined in

src/services/api.ts:145


options

options<T, R, D>(url, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.options

Defined in

src/services/api.ts:149


patch

patch<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.patch

Defined in

src/services/api.ts:163


patchForm

patchForm<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.patchForm

Defined in

src/services/api.ts:178


post

post<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.post

Defined in

src/services/api.ts:153


postForm

postForm<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.postForm

Defined in

src/services/api.ts:168


put

put<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.put

Defined in

src/services/api.ts:158


putForm

putForm<T, R, D>(url, data?, config?): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
urlstring
data?D
config?AxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.putForm

Defined in

src/services/api.ts:173


request

request<T, R, D>(config): Promise<R>

Type parameters

NameType
Tany
RAxiosResponse<T, any>
Dany

Parameters

NameType
configAxiosRequestConfig<D>

Returns

Promise<R>

Overrides

Axios.request

Defined in

src/services/api.ts:136

Vueprint is a commercial work product released under the MIT License and is provided as-is with no warranty or guarantee of support.