7.0.3 • Published 1 year ago
@scoir/api v7.0.3
Api
This utility handles standard HTTP verb requests in JavaScript for use in an authenticated application. It also provides mechanisms to get PDF, CSV, & Zip files.
Usage
initialize api instance
Pass in the fall back url function that will be used when a route is "unauthorized";
import apiFactory from '@scoir/api';
const fallBackUrlFn = () => '/login';
const api = apiFactory(fallBackUrlFn);
// use the api object
api instance
Use the instance to issue HTTP verbs
import apiFactory from '@scoir/api';
const fallBackUrlFn = () => '/login';
const api = apiFactory(fallBackUrlFn);
api.get(url).then(() => {
...
})
api.post(url, payload).then(() => {
...
})
api.put(url, payload).then(() => {
...
})
api.delete(url).then(() => {
...
})
api.patch(url, original, diff).then(() => {
...
})
getZip
Use to get a zip file at a given url.
returns new Blob([data], {type: 'application/zip'})
.
import apiFactory, { getZip } from '@scoir/api';
getZip(url).then((zipBlob) => {
...
})
getCSV
Use to get a CSV file at a given url. returns file blob.
import apiFactory, { getCSV } from '@scoir/api';
getCSV(url).then((CsvFileBlob) => {
...
})
getPdf
Use to get a Pdf file at a given url. returns byte array.
import apiFactory, { getPdf } from '@scoir/api';
getPdf(url).then((pdfByteArray) => {
...
})
7.0.3
1 year ago
7.0.2
2 years ago
7.0.1
3 years ago
7.0.0-beta.ed162590
3 years ago
7.0.0
3 years ago
7.0.0-beta.b0e6db42
3 years ago
6.2.1
4 years ago
6.2.0
4 years ago
6.1.0
4 years ago
6.0.0
6 years ago
5.2.0
6 years ago
5.1.0
6 years ago
5.0.0
7 years ago
4.1.1
7 years ago
4.1.0
7 years ago
4.0.2-1.2
7 years ago
4.0.2-1.0
7 years ago
4.0.1
7 years ago
4.0.0
7 years ago
3.0.1
7 years ago
3.0.0
7 years ago
2.0.0
7 years ago
1.0.1
7 years ago