Skip to content

Commit 860b304

Browse files
committed
fix: Improve starting example and docs
1 parent 715d7c3 commit 860b304

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var client = contentful.createClient({
7575
// This is the access token for this space. Normally you get both ID and the token in the Contentful web app
7676
accessToken: 'YOUR_ACCESS_TOKEN'
7777
})
78+
7879
// This API call will request a space with the specified ID
7980
client.getSpace('spaceId')
8081
.then((space) => {
@@ -83,6 +84,17 @@ client.getSpace('spaceId')
8384
.then((entries) => {
8485
console.log(entries.items)
8586
})
87+
88+
// let's get a content type
89+
space.getContentType('product')
90+
.then((contentType) => {
91+
// and now let's update its name
92+
contentType.name = 'New Product'
93+
contentType.update()
94+
.then((updatedContentType) => {
95+
console.log('Update was successful')
96+
})
97+
})
8698
})
8799
```
88100

@@ -98,7 +110,13 @@ The [Contentful's JS SDK reference](https://contentful.github.io/contentful-mana
98110

99111
Most methods also have examples which show you how to use them.
100112

101-
You can start by looking at the top level [`contentfulManagement`](./contentfulManagement.html) namespace.
113+
You can start by looking at the top level `contentfulManagement` namespace.
114+
115+
The `ContentfulClientAPI` namespace defines the methods at the Client level which allow you to create and get spaces.
116+
117+
The `ContentfulSpaceAPI` namespace defines the methods at the Space level which allow you to create and get entries, assets, content types and other possible entities.
118+
119+
The `Entry`, `Asset` and `ContentType` namespaces show you the instance methods you can use on each of these entities, once you retrieve them from the server.
102120

103121
From version 1.0.0 onwards, you can access documentation for a specific version by visiting `https://contentful.github.io/contentful-management.js/contentful/<VERSION>`
104122

tonic-example.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,15 @@ var client = contentful.createClient({
77
var space = await client.getSpace('spaceId')
88
// Now that we have a space, we can get entries from that space
99
await space.getEntries()
10+
11+
// let's get a content type
12+
await space.getContentType('product')
13+
.then((contentType) => {
14+
// and now let's update its name
15+
contentType.name = 'New Product'
16+
return contentType.update()
17+
.then((updatedContentType) => {
18+
console.log('Update was successful')
19+
return updatedContentType
20+
})
21+
})

0 commit comments

Comments
 (0)