# Dynamic pages with data binding

**URL:** <https://forum.builder.io/t/dynamic-pages-with-data-binding/3145>\
**Category:** Technical Questions\
**Tags:** visual-editor\
**Created:** [January 24, 2023, 12:57pm UTC](https://forum.builder.io/t/dynamic-pages-with-data-binding/3145 "2023-01-24T12:57:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuval222](https://avatars.discourse-cdn.com/v4/letter/y/d6d6ee/32.png) [@yuval222](https://forum.builder.io/u/yuval222)\
**Post date:** [January 24, 2023, 12:57pm UTC](https://forum.builder.io/t/dynamic-pages-with-data-binding/3145/1 "2023-01-24T12:57:29Z")

</div>

I’ve created a landing page that receives a slug (state name). In addition, I’ve created a data model that has a list of objects with a name field. To bind the data from the selected object, what is the correct way to get the specific object from the list based on the slug name matching the object name field?

 ![state list screenshot](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/0/0a4897c698e4c62f03af33e087f8db2eef30cfae.jpeg)

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [January 24, 2023, 2:48pm UTC](https://forum.builder.io/t/dynamic-pages-with-data-binding/3145/2 "2023-01-24T14:48:42Z")

</div>

Hi @yuval222 ,

One way you can do it is by using custom javascript code, State is a JavaScript concept that simply says an object is in a certain state, and you can update its properties and its behaviour will change accordingly. In your case, you can filter the content of the data model based on slug and then bind the new filtered state to contents.

```auto
/*
* Global objects available:
*
* state - builder state object - learn about state https://www.builder.io/c/docs/guides/state-and-actions
* context - builder context object - learn about state https://github.com/BuilderIO/builder/tree/main/packages/react#passing-data-and-functions-down
* fetch - Fetch API - https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API'
* Builder - Builder object - useful values include: Builder.isServer, Builder.isBrowser, Builder.isPreviewing, Builder.isEditing
*
*/

async function main() {
  if (Builder.isServer) {
    // Place any code here you want to only run on the server. Any  
    // data fetched on the server will be available to re-hydrate on the client
    // if added to the state object
    await fetch(someUrl)// fetch data model 
      .then(res => res.json())
      .then(data => {
        // set the data on the state object so you can access it from your components
        state.filteredData = data.find(element => element.stateName == slug); 
     });
  }
  if (Builder.isBrowser) {
    // Place code that you only want to run in the browser (client side only) here
    // For example, anything that uses document/window access or DOM manipulation
  }
}

export default main();

```

> **[Making interactive content in Builder.io with state and actions - Builder.io](https://www.builder.io/c/docs/guides/state-and-actions#:~:text=state%20and%20actions.-,Using%20state%20and%20actions,-Were%20going%20to)**
>
> Build and optimize digital experiences for any tech stack, visually.

> **[Adding custom code in the Builder.io visual editor - Builder.io](https://www.builder.io/c/docs/guides/custom-code#:~:text=Custom%20Code%20in%20the%20Builder%20Visual%20Editor)**
>
> Add custom JavaScript and CSS to your Builder content. Learn how to access browser events, state properties and add custom CSS to your pages.

> **[Connecting dynamic data in Builder's Visual Editor](https://www.builder.io/blog/builder-data#:~:text=Connecting%20dynamic%20data%20in%20Builder%27s%20Visual%20Editor)**
>
> Connect data dynamically to any component or element within your Builder dashboard
