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

204
Visualizações
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 à 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