'Is there away to redirect an API response made by one page request to another in nextjs
I'm posting data to an internal API which queries a DB to find a match and retrieves the rest of the data in the columns.I want the result of the query to be redirected to another page for display.
async function handleSubmit(e){
e.preventDefault()
const info = {referall,vclass,cover,coverPeriod}
const res = await axios.post("/api/setquote", info);
if (res.status === 200){
router.push('/pick-product')
}else{
alert('product does not exist')
}
Solution 1:[1]
Its quite easy I just needed to use the useRouter hook and pass in the result as a query parameter then call in the getintialprops of the page I'm redirecting to.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sabz |
