|
2 years ago | |
---|---|---|
src | 2 years ago | |
test | 2 years ago | |
.gitignore | 2 years ago | |
.npmignore | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
package-lock.json | 2 years ago | |
package.json | 2 years ago | |
tsconfig.json | 2 years ago | |
tsconfig.spec.json | 2 years ago |
npm install --save @ojizero/portal
Aimed to be used as a building block for API client libraries
/// In your library or definition file
import portal from '@ojizero/portal'
const client = portal({ baseUrl: 'some.base.url' }) // Initial configuration can be passed here
// Get method without path variables
client.route('someGetMethod', { path: '/some/path' })
// Get method with path variables
client.route('someGetMethodWithParam', { path: '/some/path/:withInnerVariable' })
export default client
/* ******************* */
/// In your application
import YourClient from 'your-client-module'
const client = YourClient() // You can also pass additional options to futher configure the client
const someGetMethodPromise = client.someGetMethod() // GET http://some.base.url/some/path
const someGetMethodWithParamPromise = client.someGetMethodWithParam(5) // GET http://some.base.url/some/path/5