One of the functions in my node.js app is calling an external API using the fetch function. I am trying to find the most accurate way to measure the response time for the said API.
i am using the "Date" method to do it:
let start_time = new Date().getTime();
fetch('https://jsonplaceholder.typicode.com/posts/1')
.then((res) => {
return res.json();
})
.then((data) => {
console.log('Response time:', new Date().getTime() - start_time);
Is there a better\more accurate way to do it with fetch?