Home myBlog DevNotes GitRepos Hobbies About
avatar
Recent page Back to main

Fetch url with vue by await

02 February 2022 JavaScript Web Development Vue

Handy way to fetch data by id from an url (for example from mockapi.io)

async mounted() {
  this.fetchPlan(1);
},
methods: {
    async fetchPlan(id) {
    const getPlan = await fetch(
        `https://xyz.mockapi.io/api/plan/${id}`
    );
    this.wCards = await getPlan.json();
    },
}
Linux Auth req pop stuck Git - Couldn not get the list of tags
DevCorner
Home myBlog DevNotes GitRepos Hobbies About
DevCorner © - made by Mate Molnar
Posts by tags