samedi 25 janvier 2020

React Parameter Passing To Flask Server

I am doing a project with React and Flask. I am not sure how to pass the arguments from a useEffect to a flask server.

  useEffect(() => {
    fetch("/view_all_items", { params: {game_id, id: game_id, game_id: game_id} })
    .then(response =>
      response.json().then(data => {
        setItems(data.items);
      })
    );
  }, []);

In my server I am trying to get it but it always returns none.

game_id = request.args.get("game_id")
token = request.form.get("game_id")

The route is currently

<Route exact path="/view_all_items:game_id" component={ViewAllItemsPage} />



Aucun commentaire:

Enregistrer un commentaire