SDK to use Qelos common API endpoints.
Can be used for both backend and frontend applications.
npm install @qelos/sdk
// 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.
// 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!