@onirix/api-client
v1.2.2
Published
Onirix API library wrapper
Downloads
4
Readme
Onirix API library wrapper
JavaScript wrapper library for Onirix REST API.
Usage from the browser
Using a bundler (Webpack, Rollup):
- Install the dependency:
npm install @onirix/api-client
- Import and use it within your code:
import OnirixAPI from '@onirix/api-client';
const OnirixAPIClient = new OnirixAPI("<token>");
OnirixAPIClient.getProjects().then((projects) => {
...
});
Using plain HTML
- Include the dependency within the HTML head tag:
<head>
...
<script src="https://unpkg.com/@onirix/[email protected]/dist/ox-api.umd.js">
...
</head>
- Use it from any other script:
<script>
const OnirixAPIClient = new OnirixAPI("<token>");
OnirixAPIClient.getProjects().then((projects) => {
...
});
</script>
Usage from Node.js
As this library uses fetch for http requests, a polyfill (isomorphic-unfetch) is needed when used in a Node environment.
- Install dependencies:
npm install @onirix/api-client
npm install isomorphic-unfetch
- Import the dependencies and use the library from your code:
import 'isomorphic-unfetch';
import OnirixAPI from '@onirix/api-client';
const OnirixAPIClient = new OnirixAPI("<token>");
OnirixAPIClient.getProjects().then((projects) => {
...
});