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

229
Views
Nuxt JS and Axios not fetching api data after beign deployed to Vercel

Problem Explained

I am having trouble with using Axios or fetch in nuxt. Everything works well locally but once I have deployed it to vercel it just doesn't fetch API data again. GraphQL works alright but Axios doesn't work.

I am trying to fetch blog posts from my strapi backend deployed on Heroku! I tried the fetch hook, asyncData (It just doesn't work locally nor on the server), async mounted also doesn't work.

My Code

With asyncData:

export default {
    props: {
        slug: {
            type: String,
            required: true,
        },
    },
    async asyncData({ $axios, $props }) {
        let tag = {}
        let tags = []
        await $axios
            .get(
                `http://bloggish-strapi-backend.herokuapp.com/tags?slug=${$props.slug}`
            )
            .then((res) => {
                tags = res.data
                tag = tags[0] ? tags[0] : null
            })
        return {
            tags,
            tag
        }
    },
}

Doesn't work either ways

With mounted hook

export default {
  data() {
        return {
            tags: [],
            tag: {},
        }
    },
    async mounted() {
        await this.$axios
            .get(
                `http://bloggish-strapi-backend.herokuapp.com/tags?slug=${this.$props.slug}`
            )
            .then((res) => {
                this.tags = res.data
                this.tag = this.tags[0] ? this.tags[0] : null
            })
    },
}

Doesn't work on vercel

It's deployed as an SSR project to vercel using the vercel builder

vercel.json

{
  "builds": [
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {}
    }
  ]
}

about 4 years ago · Juan Pablo Isaza
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!