forked from contentful/contentful-management.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtonic-example.js
27 lines (22 loc) · 864 Bytes
/
tonic-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var contentful = require('contentful-management')
var client = contentful.createClient({
// This is the access token for this space. Normally you get both ID and the token in the Contentful web app
accessToken: 'YOUR_ACCESS_TOKEN',
})
async function run() {
// This API call will request a space with the specified ID
var space = await client.getSpace('spaceId')
var environment = await space.getEnvironment('master')
// Now that we have a space, we can get entries from that space
await environment.getEntries()
// let's get a content type
await environment.getContentType('product').then((contentType) => {
// and now let's update its name
contentType.name = 'New Product'
return contentType.update().then((updatedContentType) => {
console.log('Update was successful')
return updatedContentType
})
})
}
run()