I wonder is there a way to pass a parameter from the client to the back-end API get Request. At this moment I hard coded the needed argument (name:"newName").
back-end route:
app.get('/api/get/beerWithComments', (req,res,next) =>{
Beer.findOne({name:'newName'}) //I want to pass the correct name, now it's hard coded.
.populate('comments').exec((err,beer) =>{
if(err) return next(err);
res.json(beer);
});
});
My action method:
export const fetchBeerWithComments =() => async dispatch => {
const res= await axios.get('/api/get/beerWithComments');
dispatch({type: FETCH_BEER_WITH_COMMENTS, payload : res.data });
}
I thought to pass the parameter here in. But I don't know if I can pass the argument to my back-end.
export const fetchBeerWithComments =(parameter) => async dispatch => {...