Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda