Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created Jun 10, 2018
Embed
What would you like to do?
module.exports = function(req, res) {
const Cosmic = require('cosmicjs')
const api = Cosmic()
const bucket = api.bucket({
slug: 'app-bucket-slug',
write_key: process.env.COSMIC_WRITE_KEY
})
bucket.addObject({
title: 'Lead - ' + (new Date()),
type_slug: 'leads',
metafields: [{
title: 'Email',
key: 'email',
type: 'text',
value: req.body.email
}],
options: {
content_editor: false,
slug_input: false
}
}).then(data => {
res.json(data)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment