Skip to content

Commit da842e9

Browse files
authored
Merge pull request #21 from microcmsio/chore/add_readme
add: README.md
2 parents 31dd5e3 + 158ce41 commit da842e9

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

README.md

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const client = createClient({
5353
</script>
5454
```
5555

56-
After, How to use it below.
56+
After, How to use `get` it below.
5757

5858
```javascript
5959
client
@@ -75,10 +75,80 @@ client
7575
.catch((err) => console.log(err));
7676
```
7777

78-
If you are using TypeScript, specify the response type.
78+
And, Api corresponding to each content are also available. example.
79+
80+
```javascript
81+
// Get list API data
82+
client
83+
.getList({
84+
endpoint: 'endpoint',
85+
})
86+
.then((res) => console.log(res))
87+
.catch((err) => console.log(err));
88+
89+
// Get list API detail data
90+
client
91+
.getListDetail({
92+
endpoint: 'endpoint',
93+
contentId: 'contentId',
94+
})
95+
.then((res) => console.log(res))
96+
.catch((err) => console.log(err));
97+
98+
// Get object API data
99+
client
100+
.getObject({
101+
endpoint: 'endpoint',
102+
})
103+
.then((res) => console.log(res))
104+
.catch((err) => console.log(err));
105+
```
106+
107+
### TypeScript
108+
109+
If you are using TypeScript, use `getList`, `getListDetail`, `getObject`. This internally contains a common type of content.
79110

80111
```typescript
81-
client.get<ResponseType>({endpoint: 'endpoint'})
112+
// Type definition
113+
type Content = {
114+
text: string,
115+
}
116+
117+
/**
118+
* // getList response type
119+
* {
120+
* contents: Content; // This is Content type
121+
* totalCount: number;
122+
* limit: number;
123+
* offset: number;
124+
* }
125+
*/
126+
client.getList<Content>({ //other })
127+
128+
/**
129+
* // getListDetail response type
130+
* {
131+
* id: string;
132+
* createdAt: string;
133+
* updatedAt: string;
134+
* publishedAt: string;
135+
* revisedAt: string;
136+
* text: string; // This is Content type.
137+
* }
138+
*/
139+
client.getListDetail<Content>({ //other })
140+
141+
/**
142+
* // getObject response type
143+
* {
144+
* createdAt: string;
145+
* updatedAt: string;
146+
* publishedAt: string;
147+
* revisedAt: string;
148+
* text: string; // This is Content type.
149+
* }
150+
*/
151+
client.getObject<Content>({ //other })
82152
```
83153
84154
# LICENSE

0 commit comments

Comments
 (0)