@qelos/sdk
TypeScript icon, indicating that this package has built-in type declarations

3.3.9 • Public • Published

@qelos/sdk

SDK to use Qelos common API endpoints.

Can be used for both backend and frontend applications.

Installation

npm install @qelos/sdk

Usage

// my-sdk.ts
import QelosSDK from '@qelos/sdk';

const sdk = new QelosSDK({appUrl: 'https://yourdomain.com', fetch: window.fetch});
export default sdk;

Note: You can inject a fetch-like function, such as node-fetch or any fetch equivalent.

Basic usage of SDK instance:

// MyPostsList.tsx
import sdk from './my-sdk';

function MyPostsList() {
  const [posts, setPosts] = useState([]);
  const [querySearch, setQuery] = useState([]);
  useEffect(() => {
    sdk.posts.getList({q: querySearch, limit: 50});
  }, [querySearch]);

  return (
    <div>
      <input type="text" placeholder="Search posts" onChange={e => setQuery(e.target.value)}/>
      {
        posts.map(post => <PostItem post={post} key={post._id}/>)
      }
    </div>
  )
}

Enjoy!

Readme

Keywords

none

Package Sidebar

Install

npm i @qelos/sdk

Weekly Downloads

1

Version

3.3.9

License

MIT

Unpacked Size

88 kB

Total Files

77

Last publish

Collaborators

  • avihainaor
  • davidmeirlevy