Skip to main content

fsxa-api: Get reference name via fetchElement

Comments

9 comments

  • Zendesk API User
    Author: Peter_Jodeleit - 11/21/2023 12:40

    The attribute is available since release 10.19.0

    0
  • Zendesk API User
    Author: neumann - 10/18/2023 11:00

    Hello André,

    you can also create an issue on github if you'd like. Or even a pull request if you feel up to it

    If you're happy with Lukas' Solution, please click on "Accept as Solution" so others know that this a valid workaround for this issue.

    Regards,

    Emre

    0
  • Zendesk API User
    Author: neo-reply-lukas - 10/17/2023 16:11

    Hello André,

    i think you mean the names you can choose when you select "rename" on a section.
    Those are pushed into CaaS but currenty not mapped by the fsxa-api. You could retrieve them with a seperate api call, by setting "keys" in additional parameters

    keys : {"page.children.children.displayname": 1, "page.children.children.name": 1 }

    (untested)
    This works, since the keys parameter disables the mapping of the fsxa-api.

    If you need the fsxa-api to pass those values, you would need to create a feature request with Crownpeak

    Best,
    Lukas

    0
  • Zendesk API User
    Author: andre-forte - 10/20/2023 10:42

    Hi neo,

    Thanks for your answer. You are right, I meant these names.

     

     

    const page: Page = await fsxaApi.fetchElement({ id: routeData.caasDocumentId, locale: FS_LOCALE, fetchOptions: { cache: 'force-cache', next: { tags: ['allRouteData'], }, }, }); const referenceNames: Page = await fsxaApi.fetchElement({ id: routeData.caasDocumentId, locale: FS_LOCALE, fetchOptions: { cache: 'force-cache', next: { tags: ['allRouteData'], }, }, additionalParams: { keys: { 'page.children.children.displayname': 1, 'page.children.children.name': 1 }, }, });

     

     

     

    I have created 2 api calls. the first ist getting alle the page data, the next one only the reference names. This works so far, but the objects are looking totally different.

    How can I merge them together? Just with a loop? or is there an easier way?

    How do you know these keys? Is there a documentation about it?

     

    Thanks in advance

    0
  • Zendesk API User
    Author: andre-forte - 10/20/2023 14:01

    Update:

    I have created this here. But the loop doesn't feel good

    referenceNames?.page.children[0].children.forEach((referenceName, index) => { const child = page.children[0].children[index]; if (child && 'id' in child && child.id === referenceName?.identifier) { page.children[0].children[index] = { ...page.children[0].children[index], ...referenceName, }; } });

     

    0
  • Zendesk API User
    Author: Peter_Jodeleit - 10/25/2023 14:14

    I understand that this "doesn't feel good" thing. We have only fractional insights in your code and challenges, so I'm unsure if we can help you further with your specific problem. This leads me to the question: Why do want to include the reference name in the first place? If there is a sane reason for this we may include it in the API. At the moment we don't see any use case for this, but we may miss something here.

    0
  • Zendesk API User
    Author: andre-forte - 11/2/2023 15:32

    Sure. I did: https://github.com/e-Spirit/javascript-content-api-library/issues/194

    Can you tell me, when this can be implemented?

    0
  • Zendesk API User
    Author: andre-forte - 10/25/2023 15:41

     We need the reference name as ids for anchor tags to scroll down to specific sections. We could also take the ids that are provided, but there are not readable by the user and on the editor in FirstSpirit you also choose this reference name when linking to a section. So if you could provide it via the default api call it would be nice. 

    or the additionalParams will include the keys to the whole request.

    So for now, when I add this here:

    additionalParams: { keys: { 'page.children.children.displayname': 1, 'page.children.children.name': 1 }, },

    the rest of the data is gone, only these keys where shown by the request. 

    0
  • Zendesk API User
    Author: Peter_Jodeleit - 10/25/2023 16:55

    Thank you for the insights. We will discuss this in the team. Do you mind to create a github issue for this? 

    0

Please sign in to leave a comment.