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
Source:stackexchange.com