Browse Source

correct usage examples

modified-method-api
ojizero 4 years ago
parent
commit
ae92811c9e
No known key found for this signature in database
GPG Key ID: FEBB7097845B0C7E
  1. 27
      README.md

27
README.md

@ -23,20 +23,29 @@ import portal from '@ojizero/portal' @@ -23,20 +23,29 @@ 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' })
export const someGetMethod = client.route({ path: '/some/path' })
// Get method with path variables
client.route('someGetMethodWithParam', { path: '/some/path/:withInnerVariable' })
export const someGetMethodWithParam = client.route({ path: '/some/path/:withInnerVariable' })
export default client
/// NOTE: ideally this wouldn't be a module level instance but this is to simplify this example 😬
/* ******************* */
/// In your application
import YourClient from 'your-client-module'
const client = YourClient() // You can also pass additional options to futher configure the client
import YourAPIClient from 'your-client-module'
const someGetMethodPromise = client.someGetMethod() // GET http://some.base.url/some/path
const someGetMethodWithParamPromise = client.someGetMethodWithParam(5) // GET http://some.base.url/some/path/5
const someGetMethodPromise = YourAPIClient.someGetMethod() // GET http://some.base.url/some/path
const someGetMethodWithParamPromise = YourAPIClient.someGetMethodWithParam(5) // GET http://some.base.url/some/path/5
```
## Documentation
## Status
This is still a work in progress :D any help is appreciated
## License
[MIT licensed](LICENSE).

Loading…
Cancel
Save