Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created June 10, 2018 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyspiro/7aca4425df89ce7cbf7960c4bcde2202 to your computer and use it in GitHub Desktop.
Save tonyspiro/7aca4425df89ce7cbf7960c4bcde2202 to your computer and use it in GitHub Desktop.
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