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

440
Views
How to redirect to another page Reactjs/nextjs sending data with post

How can I send data using post I got this

router.push({
            pathname: "/investigacion-detalle",
            query: { data: JSON.stringify(salida),},
        });

but all it's sended on the url, I want to use a redirect post, to send all data and make the redirection, but I don't know how to make that, I try making a fetch but that only give me a response from the page not the redirect

The redirect Page:

import React,{useEffect} from "react";
import { useRouter } from 'next/router'
import { withRouter } from 'next/router'
const InvestigacionDetalle = (props)=>{
  const router = useRouter()
  const handleURL = (e)=>{
    router.push('/investigacion');
  };
  useEffect(()=>{
    console.log(props.router.query.data);
  },[])
return(
    <div>
  <div>Investigacion page</div>
  <button onClick={handleURL}>test</button>
  </div>
  );
}
export default withRouter(InvestigacionDetalle);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I guess you mean making a POST request and then redirecting to another page.

You could create an async function to make the post request and then, once the request is completed, redirect to another page. For example, using axios:

const postRequest = async () => {
 try {
  const response = await axios.post(url);
  return response;
  
} catch(error) {
 throw new Error(error);
  }
}

Then you could call this function to set a state with the response for example, doing your redirect after:

postRequest().then((response) => {
//Do something with the response
}).then(() => {
router.push("/to-your-page")
}).catch((error) => {
//Do something with the error
})
about 4 years ago · Juan Pablo Isaza Report
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!