Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Last active October 7, 2018 17:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
JSON Metafield
<script src="https://unpkg.com/cosmicjs@3.0.1/cosmicjs.browser.min.js"></script>
<script>
var api = new Cosmic();
var bucket = api.bucket({
slug: 'json-bucket'
})
bucket.addObject({
title: 'Test Page',
type_slug: 'pages',
metafields: [
{
type: 'json',
key: 'json_data',
title: 'JSON Data',
value: {
test: true,
arrays: [1,2,3],
nested_objects: {
this: 'that',
the_other: 'another'
}
}
}
]
}).then(data => {
console.log(data)
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment