'React pass params with Axios post

I want to pass a params to server using Axios.post but it didn't work with 404 error any ideas??

code:

function Movie() {
  const { index } = useParams(); // get index from path /movie/:index

  const [movie, setMovie] = useState([]);
  useEffect(() => {
    Axios.post("http://localhost:3001/movie", {
      params: { id: index },
    })
      .then((response) => {
        setMovie(response.data);
      })
      .catch((err) => {
        console.log(err);
      });
  }, []);

  return (
    <body>
      abc
      {index}
      {movie.id}
    </body>
  );
}

Server:

app.post('/movie', async (req, res)=>{
  let id= req.params.id;
  let movie=[];
  movie.push(id);
  res.send(movie); 
});


Solution 1:[1]

A 404 Error means that the path /movie cannot be found on the API. Perhaps ensure that the route on your server is named correctly.

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 Sidharrth Nagappan