Browse Source

correct usage examples

tags/v1.0.0-alpha.0
ojizero 1 year ago
parent
commit
ae92811c9e
No account linked to committer's email address
1 changed files with 18 additions and 9 deletions
  1. 18
    9
      README.md

+ 18
- 9
README.md View File

@@ -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