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

294
Vistas
how to solve the problem Promise { <pending> }

I'm new in next JS, when I am trying to display my data in a particular route , its not showing , can anyone tell me why its not showing, if you have any query regarding my question please free fell to ask.

Pending Promises

import { getDataFromSheets } from "../../libs/sheets";

export default function handler(req, res) {

    const sheet =  getDataFromSheets();

    console.log(sheet)

    res.status(200).json(sheet);

}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

import { getDataFromSheets } from "../../libs/sheets";

export default async function handler(req, res) {
  const sheet = await getDataFromSheets();
  console.log(sheet);
  res.status(200).json(sheet);
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Use can solve this in a couple of ways,

Using async/await

import { getDataFromSheets } from "../../libs/sheets";

export default async function handler(req, res) {
    const sheet =  await getDataFromSheets();
    console.log(sheet)
    res.status(200).json(sheet);
}

Using .then(), .catch()

import { getDataFromSheets } from "../../libs/sheets";

export default function handler(req, res) {
    getDataFromSheets()
      .then(sheet=> res.status(200).json(sheet))
      .catch(err=> console.log(err))
}
about 4 years ago · Juan Pablo Isaza Denunciar
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