Skip to content

Instantly share code, notes, and snippets.

@mennwebs
Last active January 30, 2025 03:34
Show Gist options
  • Save mennwebs/0c7e7df8dfbf86500c57a7c88aad9483 to your computer and use it in GitHub Desktop.
Save mennwebs/0c7e7df8dfbf86500c57a7c88aad9483 to your computer and use it in GitHub Desktop.
Grist API with Next.js for Salary & Team Data
// Please check https://github.com/gristlabs/grist-api
import { GristDocAPI } from 'grist-api'
export default async function Page() {
const DOC_URL = process.env.GRIST_DOC_URL
const API_KEY = process.env.GRIST_API_KEY
const api = new GristDocAPI(DOC_URL, { apiKey: API_KEY })
const salary_data = await api.fetchTable('Salary')
const team_data = await api.fetchTable('Team')
const team = salary_data.map((person) => {
const team = team_data.find((t) => t.id === person.Team)
return { ...person, ...team }
})
// console.log(team)
if (!team) {
return {
notFound: true,
}
}
return (
<>
{/* TEAM DATA */}
</>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment