Mehdi
Mehdi
TTCTheo's Typesafe Cult
Created by Mehdi on 11/14/2024 in #questions
How to Respond to a POST Request by Rendering Page Route with Access to the Request Payload
I'm working on an unusual use case in next js where I need to respond to a POST request by rendering a Next.js page. Specifically, I want to receive a POST request at /api/cars that includes car data in the payload. After receiving this request, I need to render the /cars page using the payload data and respond with the resulting HTML. How can I pass the payload data to the page route for server-side rendering and return the rendered HTML in the response to the POST request?
4 replies