Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
vote(object) {
this.is_saving = true
if (config.cosmicjs.bucket.write_key)
object.write_key = config.cosmicjs.bucket.write_key
addObject({ bucket: config.cosmicjs.bucket }, object, (err, res) => {
// Set local storage
window.localStorage.setItem(this.poll._id, _.find(this.options_selected, { poll: this.poll._id }).value)
// Go to results page
this.showResults()
})
}
showResults() {
inquirer.prompt(question).then((answers) => {
var params = {
write_key: config.bucket.write_key,
type_slug: 'notes',
slug: Random.id().toLowerCase(),
title: answers.note_text,
content: ''
}
if(answers.note_text === ''){
console.log(chalk.red("You cannot add an empty note"))
MainMenu()
return;
}
Cosmic.addObject(config, params, (error, response) =>{
if(response.object){
console.log(chalk.green("\u2713" + " Success"))
}
if(error){
console.log(error)
}
MainMenu()
})
})
}
convo.ask("What would you like your reminder to be? etc 'I have an appointment tomorrow from 10 to 11 AM' the information will be added automatically", (payload, convo) => {
datetime = chrono.parseDate(payload.message.text)
var params = {
write_key: config.bucket.write_key,
type_slug: 'reminders',
title: payload.message.text,
metafields: [
{
key: 'date',
type: 'text',
value: datetime
}
]
}
Cosmic.addObject(config, params, function(error, response){
if(!error){
eventEmitter.emit('new', response.object.slug, datetime)
convo.say("reminder added correctly :)")
convo.end()
} else {
convo.say("there seems to be a problem. . .")
convo.end()
}
})
})
})
addItem: function(payload){
let new_item = payload.new_item;
let _this = this;
let object = {
type_slug: 'list-items',
title: new_item.title
};
Cosmic.addObject(config, object, function(err, response){
if(response.object){
let new_cosmic_item = response.object;
_this.items.push(new_cosmic_item);
_this.emitChange();
}
});
},
value: medium_link
}
]
}
if (categories) {
var tags = ''
categories.forEach(category => {
tags += category + ', '
})
params.metafields.push({
key: 'tags',
title: 'Tags',
value: tags
})
}
Cosmic.addObject(cosmic_config, params, function(err, response) {
if (response)
posts_imported.push(post)
callback()
})
}
})
}, () => {
title: 'Author',
key: 'author',
value: params.author,
type: 'text',
edit: 1
}
],
options: {
slug_field: 0,
content_editor: 0,
add_metafields: 0,
metafields_title: 0,
metafields_key: 0
}
}
Cosmic.addObject(config, object, (err, res) => {
const new_object = res.object
const message = {
_id: new_object._id,
metafield: {
message: {
value: new_object.metafields[0].value
},
author: {
value: new_object.metafields[1].value
}
}
}
callback(message)
})
}
}