Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!