Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
NextJS - log duration of an API calls

i'm working on nextJS middleware, but i've seen the documentation, stating that the middleware can rewrite routes and affect headers, but it doesn't get the response from the api call. so this code will not be able to log the duration of the call:

const { NextResponse } = require("next/server")

export default function middleware(request){
  const startTime = Date.now();
  const response = NextResponse.next();
  const endTime = Date.now();
  const duration = endTime - startTime;

  console.log(duration);

  return response
}

is there a way to log the function all duration without wrapping every api call in another function or duplicate the call in every function to log the start and end time of API call run?

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda