I'm having difficulty displaying the synchronous results of the method provided below.
I am invoking the method from another method:
var result = this.getVendor(id)
console.log(result)
Below is the fetch method code:
methods: {
async getData(id) {
const response = await fetch(`${API_URL}api/${id}`, {
method: "GET",
headers: {
authorization: `Bearer ${localStorage.token}`
}
})
.then(res => res.json())
.then(data => {
return data;
});
await response;
}
}
What is the best way to return the response
results from the getData()
function in order to display it in the console?