How to use the cosmicjs.getObject function in cosmicjs

To help you get started, we’ve selected a few cosmicjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cosmicjs / medium-backup / routes / import-posts.js View on Github external
content = post.description[0]
            if (post['content:encoded'])
              content = post['content:encoded'][0]
            if (post['pubDate'])
              published_at = post['pubDate'][0]
            if (post['atom:updated'])
              modified_at = post['atom:updated'][0]
            if (post['category'])
              categories = post['category']
            if (post['dc:creator'])
              created_by = post['dc:creator'][0]
            if (post['link'])
              medium_link = post['link'][0]
            // Test if object available
            var slug = slugify(title).toLowerCase();
            Cosmic.getObject(cosmic_config, { slug: slug }, function(err, response) {
              if (response && response.object) {
                // already added
                return callback()
              } else {
                var params = {
                  title: title,
                  slug: slug,
                  content: content,
                  type_slug: 'posts',
                  write_key: config.bucket.write_key,
                  metafields: [
                    {
                      key: 'published_at',
                      title: 'Published At',
                      value: published_at
                    },
github cosmicjs / facebook-bot / index.js View on Github external
schedule.scheduleJob(time, function(){
    Cosmic.getObject(config, {slug: itemSlug}, function(error, response){
      if(response.object.metadata.date == new Date(time).toISOString()){
        bot.say(BotUserId, response.object.title)
        console.log('firing reminder')
      } else {
        eventEmitter.emit('new', response.object.slug, response.object.metafield.date.value)
        console.log('times do not match checking again at '+response.object.metadata.date)
      }
    })
  })
})
github cosmicjs / appointment-scheduler / app.js View on Github external
app.get('/api/config', (req,res) => {
  Cosmic.getObject(config, { slug: 'site-config' }, (err, response) => {
    const data = response.object.metadata
    err ? res.status(500).json({ data: 'error' }) : res.json({ data })
  })
})
github cosmicjs / notetoself / index.js View on Github external
}).then((answers)=>{
            if(answers.allnotes === "\u001b[33mReturn\u001b[39m"){
              MainMenu()
              return;
            }
            var regexSearch = /(\w{17})/
            var newvalue = answers.allnotes.match(regexSearch)
            Cosmic.getObject(config, {slug: newvalue[0]}, (error, response)=>{
              inquirer.prompt({
                type: 'expand',
                message: chalk.blue(response.object.title),
                name: 'morecontext',
                choices: [
                  {
                    key: 'e',
                    name: 'Edit',
                    value: 'edit'
                  },
                  {
                    key: 'd',
                    name: 'Delete',
                    value: 'delete'
                  },
                  {

cosmicjs

The official client module for Cosmic. This module helps you easily add dynamic content to your website or application using the Cosmic headless CMS.

MIT
Latest version published 1 year ago

Package Health Score

42 / 100
Full package analysis