# Dynamic url cannot be picked up in state.location

**URL:** <https://forum.builder.io/t/dynamic-url-cannot-be-picked-up-in-state-location/403>\
**Category:** Technical Questions\
**Tags:** dynamic-template\
**Created:** [January 14, 2021, 10:43pm UTC](https://forum.builder.io/t/dynamic-url-cannot-be-picked-up-in-state-location/403 "2021-01-14T22:43:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![clickfrenzy](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@clickfrenzy](https://forum.builder.io/u/clickfrenzy)\
**Post date:** [January 14, 2021, 10:43pm UTC](https://forum.builder.io/t/dynamic-url-cannot-be-picked-up-in-state-location/403/1 "2021-01-14T22:43:03Z")

</div>

Hi Team, I was trying to follow the “Dynamic URLs with advanced data fetching” tutorial however I cannot get the dynamic url from “state.location”. I have only got one path which is users, if I do users/test, I couldn’t get the ‘test’ part at all from state.location.path. Do you have any ideas why? Thanks. Regards, Jane

---

<div class="post-metadata">

**Author:** ![kara](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/kara/32/80_2.png) [@kara](https://forum.builder.io/u/kara)\
**Post date:** [January 20, 2021, 1:24am UTC](https://forum.builder.io/t/dynamic-url-cannot-be-picked-up-in-state-location/403/2 "2021-01-20T01:24:11Z")

</div>

Hi Jane,

Thanks so much for reaching out! Our engineering team is going to investigate why state.location.path isn’t currently working for you. In the meantime, you can use window.location in your logic instead. For your custom JS code, you can change it to:

```
var url =
  "https://clickfrenzy-public-data-janecf.s3-ap-southeast-2.amazonaws.com/brands.json";
fetch(url)
  .then((res) => res.json())
  .then((data) => {
    state.brands = data.brands;
    var pathArray = window.location.pathname.split("/");
    var slug = pathArray[pathArray.length - 1];
    if (slug) {
      state.brand = state.brands.find((brand) => brand.slug === slug);
      console.log(state.brand);
    }
  });

```

From there, you’ll need to visit a url with the proper path, not just `/brands`, such as: [https://clickfrenzy.com/au/brands/click-frenzy-julove](https://clickfrenzy.com/au/brands/click-frenzy-julove)

Let us know if you have any questions!
