I have a simple event handler which sends a redirect to a vue page. However, I am unable to get the right format for the query parameter. Here is the snippet that does the redirect
/server/api/handle-products-ts
import {H3Event} from "h3";
export default defineEventHandler(async (event: H3Event) =>{
try {
const request: any = await readBody(event)
console.log("Redirecting to products page",request)
await sendRedirect(event, `/product?productId%3D${request.productId}`)
}catch (error){
console.log("Error",error)
}
})
In product.vue I get the route query parameter as follows
const route = useRoute()
const queryParam = route.query
Unfortunately I get the following result when I post {“productId”: “Paco Rabane”}
{“productId=Paco Rabane”:45}
I am attempting to process a POST request with a body to a product.vue page so I can get the product details from the id and additional data about the product but the only the sendDirect works, navigateTo does not work on the server side. Is there any way to accomplish this, if I cannot get the sendRedirect to work?