# yarn
yarn add react-notion-cacher-client
# npm
npm install react-notion-cacher-client
import { ReactNotionCacherClient } from "react-notion-cacher-client";
const client = new ReactNotionCacherClient({
auth: "...", // client.page.get() 만 이용할 예정이라면 auth는 작성하지 않아도 됩니다.
baseUrl: "...",
});
// 만약 auth 속성을 인스턴스 생성 시점이 아닌 다른 시점에서 하고 싶다면 client.updateAuth('TOKEN') 을 사용하세요
client.updateAuth("TOKEN");
(async () => {
console.log(
await client.page.get({
pageId: "...",
})
);
})();
각 엔드포인트의 payload는 API 문서에 적힌 내용과 같습니다. API 자체에 대한 문서는 react-notion-cacher-backend의 README.md를 참고하세요.
Endpoint | Function |
---|---|
POST /auth/signin | client.auth.signIn() |
POST /auth/signup | client.auth.signUp() |
DELETE /auth/account | client.auth.deleteAccount() |
GET /page | client.page.get() |
GET /pages | client.page.list() |
PATCH /page/:pageId | client.page.patch() |
DELETE /page/:pageId | client.page.delete() |
자주 사용되는 오브젝트는 별도의 타입으로 분리되어 있습니다.
PageObject
type PageObject = {
pageId: string;
pageCode: string | undefined;
domain: string;
cachedAt: string;
recordMap: any;
};