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

235
Vistas
How would I use date in Next.js api to generate boolean if todo item should be visible?

I might have gotten things all messed up, but I'm trying to build something using only Next.js where if a certain date has passed, my todo items should become visible.

I know I can't simply use new Date() in the client, because that would make it possible for anyone to manipulate the time of the client to render the content visible.

So my question is, it is possible doing something like this with Next.js's built in api?

/api/todos.js

export default function handler(req, res) {
  const now = new Date();

  res.status(200).json([
    {
      title: 'Todo 1',
      id: 1,
      isOpened: false,
      canBeOpened: now >= new Date('2021-12-01'),
    },
    {
      title: 'Todo 2',
      id: 1,
      isOpened: false,
      canBeOpened: now >= new Date('2021-12-02'),
    },
  ]);
}

I'm planning on hosting this on netlify, but I'm not sure what time they might be using. Is this approach possible?

about 4 years ago · Juan Pablo Isaza
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