async function timeRequest (request, timeout = null) {
  // This is non-perfect because of the js event loop, but enough
  // of a proximation. Don't use for mission-critical timing.
  const startTime = new Date().getTime()
  let config = {}
  if (timeout) {
    config.timeout = timeout
  }
  let response
  try {
    response = await axios.get(request.url, config)
  } catch (e) {
    console.debug(`Error with request for ${request.url}: ${e}`)
    return { request, response: null, millis: null }
  }
  const millis = new Date().getTime() - startTime
  return { request, response, millis }
}
/**
* Fetches a url and times how long it took the request to complete.
* @param {Object} request {id, url}
* @param {number?} timeout
* @returns { request, response, millis }
*/
Fetches a url and times how long it took the request to complete.
Fetches a url and times how long it took the request to complete .
async function timeRequest (request, timeout = null) {
  const startTime = new Date().getTime()
  let config = {}
  if (timeout) {
    config.timeout = timeout
  }
  let response
  try {
    response = await axios.get(request.url, config)
  } catch (e) {
    console.debug(`Error with request for ${request.url}: ${e}`)
    return { request, response: null, millis: null }
  }
  const millis = new Date().getTime() - startTime
  return { request, response, millis }
}
async function timeRequest ( request , timeout = null ) { const startTime = new Date ( ) . getTime ( ) let config = { } if ( timeout ) { config . timeout = timeout } let response try { response = await axios . get ( request . url , config ) } catch ( e ) { console . debug ( ` ${ request . url } ${ e } ` ) return { request , response : null , millis : null } } const millis = new Date ( ) . getTime ( ) - startTime return { request , response , millis } }
Fetches a url and times how long it took the request to complete.
Fetches a url and times how long it took the request to complete .
// This is non-perfect because of the js event loop, but enough // of a proximation. Don't use for mission-critical timing.