My issue currently is trying to verify a link passes a requirement, and if so, pass the data to a new router. Right now, I have a few problems with implementing this; most notably, I’m using history.push() to route to a new component, so I don’t know how to pass props in that event. Secondly, I’m unsure how I should set the URL, whether to use query params for it or not. I’m just really clueless with operating with router links and the best practices, so I would appreciate any help.
My history.push():
const APIcall = () => { axios .post(`http://127.0.0.1:8000/check_url/`, LinkInput, { headers: { “Content-Type”: “application/json”, “X-CSRFToken”: csrftoken, }, withCredentials: true, // withCredentials: true to make cors requests }) .then((res) => { if (res.data.status == “200”) { history.push(`/` + LinkInput); } else { console.log(“not valid”); setInvalidInput(“”); setLoading(false); } }); };
It’s parent component in this case owns the routers/switch.
submitted by /u/charles_atlas_12
[link] [comments]