[Vuejs]-Vercel.com Hosting: Development & Production URLs

0👍

In Poems.vue the url should be /poems and NOT http://localhost:8081/poems.

Browser will use correct domain automatically. You need to put / at the beginning to indicate that the path is absolute, and not relative to the current page.

Complete code:

fetchPoems(){
        return axios({
          method: 'get',
          url: '/poems',
          headers: {
            'Content-Type': 'application/json',
          },
        })
        .then((res)=>{
          this.poems = res.data.poems;
        })
        .catch((err)=>{
          console.log(err);
        });
      }

Leave a comment