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