@alpakaio/alpaka-native-request
v1.0.2
Published
Request facade used by Alpaka React Native apps
Downloads
8
Readme
alpaka-native-request
Request facade used by Alpaka React Native apps.
TOC
Installation
Using npm:
npm install --save @alpakaio/alpaka-native-request
Usage
import UserAgent from '@alpakaio/alpaka-native-request';
API
| Method | Return Type | iOS | Android | Windows | Since |
| ----------------------------------------------------------------- | ------------------- | :--: | :-----: | :-----: | ------ |
| createRequest(tenant, [token]) | Promise<Request>
| ✅ | ✅ | ✅ | 1.0.0 |
| createInstance() | Promise<Request>
| ✅ | ✅ | ✅ | 1.0.0 |
createRequest()
Creates or gets a current axios instance configured to communicate with the Alpaka API
Examples
const request = await createRequest('test');
const response = request.get('version');
console.log(response.data.version);
createRequest((request) => (request.get('version'))).then((response) => {
console.log(response.data.version);
});
createInstance()
Creates an axios instance with an Alpaka user agent assigned
Examples
const axios = await createInstance();
const response = axios.get('https://alpaka.alpaka.io/api/v3/version');
console.log(response.data.version);
createInstance((axios) => (axios.get('https://alpaka.alpaka.io/api/v3/version'))).then((response) => {
console.log(response.data.version);
});
Release Notes
See the CHANGELOG.md.