Declarative library for describing endpoints.
npm:
npm install @ryniaubenpm2/porro-incidunt-fugiat
yarn:
yarn add @ryniaubenpm2/porro-incidunt-fugiat
Describe your request scheme
import @ryniaubenpm2/porro-incidunt-fugiat from '@ryniaubenpm2/porro-incidunt-fugiat';
export const requests = @ryniaubenpm2/porro-incidunt-fugiat('10.16.0.140', 9001)
.group('list', {
get: {
all: 'get-all-lists',
},
post: {
save: 'save-list',
create: 'get-empty-list'
}
})
.group('ports', {
get: {
ports: (count) => `get-ports?count=${count}`,
}
})
.end();
And send your requests to any place
import { requests } from 'requests';
const showLists = async () => {
try {
const response = await fetch(requests.list.get.all);
const answer = await response.json();
console.log(answer);
} catch (error) {
console.error(error);
}
}
import { requests } from 'requests';
import axios from 'axios';
const showLists = async () => {
try {
const response = await axios.get(requests.list.get.all);
console.log(response.data);
} catch (error) {
console.error(error);
}
}