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

285
Views
How can I use re-fetch data in Next.js when an endpoint is hit?

I am using a webhook which triggers a request to an URL when a message is POST in the channel. I am using getServerSideProps to fetch data from the server,

export async function getServerSideProps({ req }) {
  console.log("\x1b[36m%s\x1b[0m", "get req to serverside");
  let messages = {};
if (req.method === "GET") {
messages = await getMessages(process.env.NEXT_PUBLIC_ROCKET_CHAT_CONF_RID,req.cookies)
} 

if (req.method === "POST") {
// does a re-fetch but it is not sending me the data back
messages = await getMessages(process.env.NEXT_PUBLIC_ROCKET_CHAT_CONF_RID,req.cookies)
}
  return {
    props: {
      messages,
      cookies: req.cookies,
    },
  };
}

As quoted here in the doc,

Server-side Rendering: The HTML is generated on each request. To make a page use Server-side Rendering, export getServerSideProps. Because Server-side Rendering results in slower performance than Static Generation, use this only if absolutely necessary.

How can I re-fetch data and make the message sending part realtime?

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!