Href use in API request and using subdomains

i am using Bootstrap in one of my react project and using Dropdown.Item as submenu it will fetch the desired search results and show on the browser just under the menu.

as you see once i click the item it will take me to subdomain link (http://localhost:3000/#/action-2), i amjust not sure what will be the best practice(shell i keep it as it is or remove the href="#/action-2" so the link will be(http://localhost:3000) even after its clicked, i mean i will be doing the get/post request to server once the option is clicked to return the items back for display, also if some one can please explain that how you read #/ in the URL as i can see if i dont use the # in href it doesnt show at all the menu

Any Advice guys. Thanks.


                <Dropdown.Toggle variant="secondary" id="dropdown-basic">




                  <Dropdown.Item href="#/action-2" onClick={yougaPropsSelected}>



Typically, you should use encodeURIComponent method to encode your URI before invoke the API request. For example:
'#/action-2' will become '%23%2Faction-2'.
The key is escaping ‘#’ because the API request will trunc whatever behind(including) the first ‘#’ as the URL.

1 Like

@BreakUps Thanks for the explanation :+1:

Sorry, I may have misunderstood your question. location.href.hash should be what you want.

1 Like