Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Last active October 7, 2018 17:27
Show Gist options
  • Save tonyspiro/407091c710984ab01b966206eab01af3 to your computer and use it in GitHub Desktop.
Save tonyspiro/407091c710984ab01b966206eab01af3 to your computer and use it in GitHub Desktop.
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