nuxt-community / feed-module

Everyone deserves RSS, ATOM and JSON feeds!
MIT License
227 stars 36 forks source link

How can i setup create function? #1

Closed PavelSmertin closed 6 years ago

PavelSmertin commented 6 years ago

I have defined create function in my nuxt.config.js file. axios is not imported in nuxt.config.js and i have an error:

ReferenceError: axios is not defined

  feed: [{
      path: '/rss_export', // The route to your feed.
      async create (feed) {
        feed.options = {
          title: 'title',
          description: 'describtion',
        }

        const posts = await axios.get('http://localhost:3000/v1/news/').data

        posts.forEach(post => { 
          feed.addItem({
              title: 'test'
          })

          feed.addCategory('funny')

          feed.addContributor({
              // some details
          })
        })
      },
      cacheTime: 1000 * 60 * 15, 
      type: 'rss2' 
    }
  ],

what is the best way to setup create function? Give me code example please

manniL commented 6 years ago

Hey @pashtetbezd This looks fine so far, but you need to import axios on top of your file:

const axios = require('axios')

// Your nuxt config here
PavelSmertin commented 6 years ago

thnx! it works