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

205
Vistas
How to get specific data from Google Sheets API?

I'm trying to use Google Sheet as a database, using Next.js to build this app. Unfortunately, I've suffered some problems over a few days.

The problems are I want to get data by searching for a specific id, but I can't figure out how to solve this problem. Here is the data example:

enter image description here

How to use the report id to get the name and the row of data? If I search for reportId = 12, I want to have three data in the response.

And the other question is how to update a specific ID by using Google Sheets API? I've seen using batchGetDataByFilter, but still don't know how to use it.

Here is my code

import { google } from 'googleapis';
import moment from 'moment';
import { auth } from '../../lib/google';

const handler = async (req, res) => {
  if (req.method !== 'GET') {
    return res.status(405).send('Only for GET requests');
  }

  try {
    const { reportId } = req.query;
    const sheets = google.sheets({ version: 'v4', auth });
    const sheet_response = sheets.spreadsheets.values.batchGetByDataFilter({
      spreadsheetId: process.env.GOOGLE_SHEET_ID,
      requestBody: {
        valueRenderOption: 'FORMATTED_VALUE',
        majorDimension: 'ROWS',
        dataFilters: [{}],
      },
    });
    const data = sheet_response?.data?.values;
    return res.status(200).json({});
  } catch (error) {
    return res.status(500).send({ message: error.message ?? 'Something went wrong' });
  }
};

export default handler;
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