# Is it possible to fetch the targeting parameters?

**URL:** https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674
**Category:** Technical Questions
**Created:** [September 30, 2022, 1:53pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674 "2022-09-30T13:53:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ersin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ersin/32/1849_2.png) [@ersin](https://forum.builder.io/u/ersin)
#### Post date: [September 30, 2022, 1:53pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/1 "2022-09-30T13:53:28Z")

</div>

Topic name says it all: can I get the targeting parameters of a content item as part of the content API response?

My use case is that I have a `drawer` section model that represents a menu that slides out from the left or the right. Left/right are distinguished using a `drawerOrientation` custom targeting parameter.

This setup works fine for fetching my drawer content in my layout, because I can specify whether I want a `left` or `right` drawer.

But for editing purposes, I have a dedicated editing page that just fetches whichever drawer content item has been opened in the Visual Editor. There’s no knowledge beforehand of whether it’s `left` or `right`, but various CSS stylings on my Next.js page depend on knowing this, so I’d like to parse it out of the targeting attributes for that content item if possible.

---

<div class="post-metadata">

### Author: ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)
#### Post date: [October 3, 2022, 7:07pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/2 "2022-10-03T19:07:04Z")

</div>

Hey @ersin currently there is not a set value in the content object that shows the targeting attributes for a given content entry.

That being said, the query for the content entry will show in the content object, so for example this call to the content api:  
[https://cdn.builder.io/api/v2/content/page?apiKey=e37b966ec695434bb21e97442a4a9f46&userAttributes.urlPath=%2Fparent-symbol&userAttributes.locale=en-US](https://cdn.builder.io/api/v2/content/page?apiKey=e37b966ec695434bb21e97442a4a9f46&userAttributes.urlPath=%2Fparent-symbol&userAttributes.locale=en-US)

includes the user attributes `locale=en-US` and `urlPath=/parent-symbol` and you can see them in the query object inside the response:

```auto

{
"results": [
...
   "query": [
       {
           "@type": "@builder.io/core:Query",
           "operator": "is",
           "property": "urlPath",
           "value": "/parent-symbol"
       },
       {
           "@type": "@builder.io/core:Query",
           "operator": "is",
           "property": "locale",
           "value": [
                  "en-US"
            ]
       }
   ],
...

```

So the content object includes the query that fetched it. So if you have that available you can pass to state as a [data prop](https://github.com/BuilderIO/builder/tree/main/packages/react#passing-data-and-functions-down).

Do you think this would be sufficient for your use case?

---

<div class="post-metadata">

### Author: ![ersin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ersin/32/1849_2.png) [@ersin](https://forum.builder.io/u/ersin)
#### Post date: [October 3, 2022, 7:25pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/3 "2022-10-03T19:25:31Z")

</div>

Yup that works, thanks @TimG!

---

<div class="post-metadata">

### Author: ![ersin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ersin/32/1849_2.png) [@ersin](https://forum.builder.io/u/ersin)
#### Post date: [October 4, 2022, 6:21am UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/4 "2022-10-04T06:21:58Z")

</div>

Argh actually, I answered too soon. The problem is that my query doesn’t have the targeting parameter to begin with, it’s just simply saying “load this content model.”

---

<div class="post-metadata">

### Author: ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)
#### Post date: [October 4, 2022, 5:55pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/5 "2022-10-04T17:55:38Z")

</div>

Looking over the use case, is there a reason this would be based off of targeting parameters? It almost sounds like `left` and `right` could just as easily be[passed in as values on the data prop](https://github.com/BuilderIO/builder/tree/main/packages/react#passing-data-and-functions-down) to state?

Why does this need to be a targeting parameter?

---

<div class="post-metadata">

### Author: ![ersin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/ersin/32/1849_2.png) [@ersin](https://forum.builder.io/u/ersin)
#### Post date: [October 4, 2022, 6:29pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/6 "2022-10-04T18:29:17Z")

</div>

The main reason is that there’s one `drawer` model and there needs to be a way to select which kind of drawer content item should be rendered, either left or right. I need some kind of targeting parameter for that.

A simple, no-nonsense fix would involve splitting my `drawer` model into a `left-drawer` and `right-drawer` model and creating content items for them separately. That’s what I had originally, but I found that solution unsatisfying and inelegant. Drawer content should just be drawer content. Otherwise, I end up having to write `left-drawer` and `right-drawer` all over my codebase.

---

<div class="post-metadata">

### Author: ![TimG](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/timg/32/714_2.png) [@TimG](https://forum.builder.io/u/TimG)
#### Post date: [October 4, 2022, 6:45pm UTC](https://forum.builder.io/t/is-it-possible-to-fetch-the-targeting-parameters/2674/7 "2022-10-04T18:45:12Z")

</div>

Do you have a link to an example content entry? How do the left and right drawers differ? If it is just a CSS thing, then you could just have it be conditional based on state passed through data prop.

Without seeing in practice I might be missing some major components of the implementation though
