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