[Vuejs]-How to insert a params in Fetch GET request?

1👍

Change " to back ticks to make it a string literal and add it with interpolation.

async fetch(id){      
    const res = await fetch(
      `http://localhost:5000/searchData/${id}`,
        {
          method:"GET"
        }
    );
    const data = await res.json()
    console.log(data)
  }

Using this style of interpolation makes it so much easier to read when you have a few params

Leave a comment