Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created January 16, 2018 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyspiro/8571f70e9f50da2d79f55ef799be7c00 to your computer and use it in GitHub Desktop.
Save tonyspiro/8571f70e9f50da2d79f55ef799be7c00 to your computer and use it in GitHub Desktop.
Cosmic JS NPM module - Add Object
const params = {
"title": "Cosmic JS Example",
"type_slug": "examples",
"content": "Learning the Cosmic JS API is really fun and so easy",
"metafields": [
{
"key": "Headline",
"type": "text",
"value": "Learn Cosmic JS!"
},
{
"key": "Author",
"type": "text",
"value": "Quasar Jones"
}
]
}
const bucket = Cosmic.bucket({
slug: 'bucket-slug',
write_key: ''
})
bucket.addObject(params).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment