There is a neat URL with query parameters that I am working with.
My goal is to extract the 'id' query parameter on the client side.
static async getInitialProps({req, query: { id }}) {
return {
postId: id
}
}
render() {
const props = {
data: {
'id': this.props.postId // 'id' is currently undefined
}
}
return (
<Custom {...props}>A component</Custom>
)
}
This is how my Express endpoint is set up.
app.post(
'/post/:id',
(req, res, next) => {
let data = req.body;
console.log(data);
res.send('Ok');
}
);
However, the output on the server side shows this.
{ id: 'undefined' }
I have searched through the documentation and GitHub issues but I am unable to figure out the reason behind this issue.