# Href use in API request and using subdomains

**URL:** https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491
**Category:** web dev
**Created:** [July 7, 2020, 1:54pm UTC](https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491 "2020-07-07T13:54:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Umair\_Ashraf](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/umair_ashraf/32/11705_2.png) [@Umair\_Ashraf](https://forum.kirupa.com/u/Umair_Ashraf)
#### Post date: [July 7, 2020, 1:54pm UTC](https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491/1 "2020-07-07T13:54:39Z")

</div>

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.

 ![image](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/2X/a/a12c3570990603eaa27018a396dc9ab5a97d72ec.png)

as you see once i click the item it will take me to subdomain link ([http://localhost:3000/#/action-2](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](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>

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

                  {yogaPropsState}

                </Dropdown.Toggle>

                <Dropdown.Menu>

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

                    Action

                  </Dropdown.Item>

```

---

<div class="post-metadata">

### Author: ![BreakUps](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@BreakUps](https://forum.kirupa.com/u/BreakUps)
#### Post date: [July 8, 2020, 6:03pm UTC](https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491/2 "2020-07-08T18:03:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Umair\_Ashraf](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/umair_ashraf/32/11705_2.png) [@Umair\_Ashraf](https://forum.kirupa.com/u/Umair_Ashraf)
#### Post date: [July 9, 2020, 4:29pm UTC](https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491/3 "2020-07-09T16:29:39Z")

</div>

@BreakUps Thanks for the explanation 👍

---

<div class="post-metadata">

### Author: ![BreakUps](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@BreakUps](https://forum.kirupa.com/u/BreakUps)
#### Post date: [July 10, 2020, 12:13pm UTC](https://forum.kirupa.com/t/href-use-in-api-request-and-using-subdomains/643491/4 "2020-07-10T12:13:14Z")

</div>

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