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

145
Views
How to fetch data from google sheet in next app

I'm trying google sheet as a mini database with the nextJs app but how to use getStaticPaths to get specific page data. in this app I'm not using google sheet API I'm getting data as JSON.

export const getStaticPaths = async () => {
    const res = await fetch('https://docs.google.com/spreadsheets/d/1OgT7pYpT__3y1qgC6Nlb8dE759drBFTSWN3H0g5M_Ps/gviz/tq?tqx=out:json')
    const text = await res.text();
    const data = await JSON.parse(text.substr(47).slice(0, -2));

    const paths = data.table.rows.map((table) => {
        return {
            params: {
                title: table.c[1].v
            }
        }
    })

    return {
        paths,
        fallback: false
    }
}

export const getStaticProps = async (context) => {
    const title = context.params.title;
    const res = await fetch('https://docs.google.com/spreadsheets/d/1OgT7pYpT__3y1qgC6Nlb8dE759drBFTSWN3H0g5M_Ps/gviz/tq?tqx=out:json')

    const text = await res.text();
    const data = await JSON.parse(text.substr(47).slice(0, -2));

    return {
        props: { posts: data }
    }
}

const Title = ({ posts }) => {
    return (
        <>
            <div>
                <h1>{ posts.table.rows[0].c[0].v }</h1>
            </div>
        </>
    )
}

export default Title;

how to get data in dynamic page from google sheet.

about 4 years ago · Juan Pablo Isaza
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!