Static GitHub Issues

[1729] Components with Axios

prev: How to add middleware from module ?
next: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

Hey! I have a component that I want to load a menu from my api (WP-API), but it is returning null. Here is my component code:

<script>
import Axios from '~/plugins/axios'

export default {
  props: ['sitename'],

  mounted () {
    this.getMenus()
  },

  data () {
    return {
      menus: []
    }
  },

  created () {
    this.$log.info(this.getMenus())
  },

  methods: {
    getMenus () {
      Axios.get(`wp-api-menus/v2/menus`)
      .then((res) => {
        this.menus = res.data
      })
    }
  }
}
</script>
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1551">#c1551</a>)</em></sub></div>