Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Combine code snippets into one code snippet #42

Open
korydraughn opened this issue Aug 9, 2024 · 0 comments
Open

README: Combine code snippets into one code snippet #42

korydraughn opened this issue Aug 9, 2024 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@korydraughn
Copy link

The README can show one single code snippet that explains how to use the wrapper/client.

The lines in the README can become code comments.

With that in place, the developer looking to use this code can easily copy the example and give the wrapper a try.

For example:

import { Wrapper } from 'irods_client_http_typescript'
import { CollectionTypes } from "irods-http-api-wrapper"

// Create a url configuration object, containing info about
// the irods http api that's running on your local machine.
const urlComponents: URLComponentsType = {
    host: '<host>',
    port: '<port>',
    version: '<version>',
}

// Create a wrapper object, passing in the url components, as
// well as the username and password you want to log in with.
const api = new Wrapper(urlComponents, '<username>', '<password>')

// Authenticate the wrapper object within an asynchronous context.
(async () => {
    await api.authenticate()
})

// Declare type of res if working in typescript, otherwise just
// put 'let res'
let res: CollectionTypes.CollectionCreateResponse | null
let lpath = "/tempZone/home/user/newCollection"

(async () => {
    res = await api.collections.create({
        lpath: lpath
    })
})
@korydraughn korydraughn added the documentation Improvements or additions to documentation label Aug 9, 2024
farbs03 added a commit to farbs03/irods_client_http_typescript that referenced this issue Aug 15, 2024
- Added demonstration for error handling
korydraughn pushed a commit that referenced this issue Aug 15, 2024
- Added demonstration for error handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants