REACT Voting app - delete a poll [KIND OF SOLVED]

REACT Voting app - delete a poll [KIND OF SOLVED]
0

#1

So my plan was when in the Edit poll page, you have the option to delete the poll.

The delete function works but then what?
How do I handle the fact that this poll no longer exists?
I was thinking redirect back to the home page or a message saying “Poll deleted” but both need to re-direct away from this poll.


#2

Not sure what the problem is with redirecting?


#3

Problem is I don’t know how to. And if I do, how do I send a message to the user? Pass a query string?


#4

I have almost no experience with React, but I suppose you are using a router? Or is the server handling the routing?


#5

I am using REACT router but as it is a Full stack app, Node does some routing too. I’m just not sure what to do so I was hoping others who have done it can point me to the best option.


#6

If you are using the React router this might help:


#7

Ok that gives me a few options but it doesn’t look like a 5 minute job and I am going out now so I will check it later.
Thanks.


#8

Seems like I can just do:
location.replace('/'); after doing the delete API call.

More about the location object