Created
January 16, 2018 21:15
-
-
Save tonyspiro/8571f70e9f50da2d79f55ef799be7c00 to your computer and use it in GitHub Desktop.
Cosmic JS NPM module - Add Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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