UNPKG

2.64 kBMarkdownView Raw
1# api-axios
2
3> A package wrapping [@av/api-core](../api-core/README.md) with axios and native ES6 Promise.
4
5[![Version](https://img.shields.io/npm/v/@availity/api-axios.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/api-axios)
6
7## Install
8
9### NPM
10
11```bash
12$ npm install @availity/api-axios @availity/api-core
13```
14
15### Yarn
16
17```bash
18$ yarn add @availity/api-axios @availity/api-core
19```
20
21Polyfill `Promise` if needed:
22
23### NPM
24
25```bash
26$ npm install es6-promise
27```
28
29### Yarn
30
31```bash
32$ yarn add es6-promise
33```
34
35## Usage
36
37```js
38import { userApi } from '@availity/api-axios'
39
40function async getUser() {
41 const user = await userApi.me();
42}
43```
44
45## API Definitions
46
47- `AvMicroserviceApi`
48- `AvProxyApi`
49- `avCodesApi`
50- `avDisclaimersApi`
51- `avFilesApi`
52- `avFilesDeliveryApi`
53- `avLogMessagesApi`
54- `avNavigationApi`
55- `avNotificationApi`
56- `avOrganizationsApi`
57- `avPdfApi`
58- `avPermissionsApi`
59- `avProvidersApi`
60- `avRegionsApi`
61- `avSettingsApi`
62- `avSlotMachineApi`
63- `avSpacesApi`
64- `avUserApi`
65- `avUserPermissionsApi`
66- `avWebQLApi`
67
68Details about each api can be found [here](../api-core/src/resources/README.md)
69
70```js
71// complete example
72import AvApi, {
73 AvMicroserviceApi,
74 AvProxyApi,
75 avCodesApi,
76 avDisclaimersApi
77 avFilesApi,
78 avFilesDeliveryApi,
79 avLogMessagesApi,
80 avNavigationApi,
81 avNotificationApi,
82 avOrganizationsApi,
83 avPdfApi,
84 avPermissionsApi,
85 avProvidersApi,
86 avRegionsApi,
87 avSettingsApi,
88 avSlotMachineApi,
89 avSpacesApi,
90 avUserApi,
91 avUserPermissionsApi,
92 avWebQLApi,
93} from '@availity/api-axios';
94```
95
96## Create API Definitions
97
98Create new API definitions by extending `AvApi`. Extending `AvApi` provides services the behaviors described in [@api-core/README#features](../api-core/README.md#features)
99
100```js
101import AvApi from '@availity/api-axios';
102
103class AvExampleResource extends AvApi {
104 constructor() {
105 super({
106 name: 'exampleApi',
107 });
108 }
109}
110
111export default new AvExampleResource();
112```
113
114## Create Proxy API Definitions
115
116Create new API definitions by extending `AvApiProxy`. Extending `AvApiProxy` provides services the behaviors described in [@api-core/README#features](../api-core/README.md#features) as well as building the url to match your tenant's proxy REST conventions.
117
118```js
119import { AvApiProxy } from '@availity/api-axios';
120
121class AvExampleResource extends AvApiProxy {
122 constructor() {
123 super({
124 tenant: 'myhealthplan',
125 name: 'patients',
126 });
127 }
128}
129
130export default new AvExampleResource();
131```