Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
How to convert some Nuxt code into some Vue?

How can I convert this Nuxt script into a Vue compatible one?

<script>
export default {
  components: {
    FeaturedProduct
  },
  async asyncData({ $axios }) {
    try {
      let response = await $axios.$get(
        'http://localhost:5000/api/products'
      )

      console.log(response)
      return {
        products: response.products
      }
    } catch (error) {}
  }
}
</script>

How can I go about it in Vue? If I remove the $ it gives me an error saying

axios not defined

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This would be the syntax in Vue (assuming you've installed axios for Vue)

<script>
export default {
  async created() {
    try {
      let response = await this.axios(
        'http://localhost:5000/api/products'
      )

      console.log(response)
      this.products = response.data.products
    } catch (error) {}
  }
}
</script>

A working example could be found here: https://github.com/kissu/vue2-axios/blob/master/src/App.vue

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!