Next.js Discord

Discord Forum

My site seems to not getting the new data from database.

Answered
ice cream posted this in #help-forum
Open in Discord
Heyoo, in nextJS, how can I have a page that is Server side that gets a certain number of data in the database? But when I upload it into production, when I add a new one, and refresh it, it's not showing. What seems to be the problem in that? I can show you the code here : (I guess what I'm looking for is an equivalent of getServerSideProps)
import Page from "@/components/Page"
import { ProjectsRecord, XataClient } from "@/xata"
import Image from "next/image"
import Link from "next/link"
import React from "react"
const page = async () => {
  const xata = new XataClient()
  const projects = await xata.db.Projects.getAll() // this just returns around 2-5 if that matters.
  return (
    <Page className="flex-col !overflow-auto">
      <div>
      <div className="flex w-full flex-wrap justify-evenly">
        {projects.map((project: ProjectsRecord) => {
          if (!project.projectName) return
        return //the html elements here. 
        })}
      </div>
    </Page>
  )
}

export default page
Answered by B33fb0n3
If your goal changed to I just want it to be dynamic, then you can also export:
export const dynamic = 'force-dynamic' // forces the page to be dynamic
View full answer

10 Replies

I tried doing that but it gave me no data still.
The same data was loaded even though I added a new one on the data base
@ice cream The same data was loaded even though I added a new one on the data base
Can you share a https://codesandbox.io/ repro repo? You don't want to share the secrets, so replace your data source with the world api: http://worldtimeapi.org/
@ice cream?
Hello! Sorry I got busy with other things, How can I upload it to the repo? But my repo is here : https://github.com/Blueguy0301/portfolioV2/blob/master/src/app/projects/page.tsx
My current solution was importing cookies to make it dynamic but I never used it. It was just there to make it dynamic
@ice cream My current solution was importing cookies to make it dynamic but I never used it. It was just there to make it dynamic
If your goal changed to I just want it to be dynamic, then you can also export:
export const dynamic = 'force-dynamic' // forces the page to be dynamic
Answer
@ice cream is your issue solved? If so, please mark solution
Thanks !