There are currently two components in my project that are nearly identical. The HTML structure and CSS rules are the same, with the only difference being the GET request made in the mounted()
lifecycle hook. One component fetches all visited places, while the other fetches all wishlisted places. Despite the different data being returned, the response structure is the same for both requests.
My dilemma is whether to merge these two components into one. If I decide to do so, how can I determine which type of data to fetch - visited or wishlisted places? One possible solution could be to base this decision on the URL path, such as checking for
http://localhost:8080/#/Admin/visited
to fetch visited places and http://localhost:8080/#/Admin/wishlist
to fetch wishlisted places.
Furthermore, what would be an appropriate name for this combined component, considering it will be responsible for fetching both types of places? Additionally, what would be a suitable name for the data property that will replace wishlist
and visited
?