🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@greenpress/sdk

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@greenpress/sdk

SDK for Greenpress API

latest
Source
npmnpm
Version
2.0.21
Version published
Maintainers
3
Created
Source

@greenpress/sdk

SDK to use Greenpress common API endpoints.

Can be used for both backend and frontend applications.

Installation

npm install @greenpress/sdk

Usage

// my-sdk.ts
import GreenpressSDK from '@greenpress/sdk';

const sdk = new GreenpressSDK({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!

FAQs

Package last updated on 15 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts