# Hubspot API | Get value from a div element

**URL:** <https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [January 25, 2024, 3:02pm UTC](https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650 "2024-01-25T15:02:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [January 25, 2024, 3:02pm UTC](https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650/1 "2024-01-25T15:02:56Z")

</div>

I have created a module with FileId, Text input’s ., I want to make the FileId value dynamic code.  
Can someone give me idea why I cannot get the FileId number as dynamic from my servercode. I want to get the value number from the div element from my html to my Server code so everytime a random ID’s it displays all the data base on that ID’s.  
Here’s my serverside code:

```lia-code-sample
const axios = require('axios');

exports.main = async (context, sendResponse) => {
 const fileId = context.body.fileId; // Assuming the fileId is passed in the request body

 if (!fileId) {
 sendResponse({ body: 'File ID not provided in the request', statusCode: 400 });
 return;
 }

 var config = {
 method: 'get',
 maxBodyLength: Infinity,
 url: `https://api.hubapi.com/files/v3/files/${fileId}/signed-url?expirationSeconds=900`,
 headers: {
 Authorization: 'Bearer token-sample-here21321312312',
 },
 };

 try {
 const response = await axios(config);
 const data = JSON.stringify(response.data);
 sendResponse({ body: data, statusCode: 200 });
 } catch (error) {
 console.log(error);
 sendResponse({ body: error.message, statusCode: 400 });
 }
};

```

Here’s my client-sidecode:

```lia-code-sample
<div class="file-wrapper">
 <div id="fileIdNumber" class="file_id_val" data-file-id="{{ module.file_id }}">
 {{ module.file_id }}
 </div>
 <a id="file_link_href" class="file_text_val" href="" target="_blank">
 {{ module.file_text }}
 </a>
 <br>
 <hr>
 <div class="file-wrapper">
 <div id="file-link"></div>
 <span class="expires-at-label"></span>
 </div>
</div>

<script>
var requestOptions = { 
 'method': 'GET',
 'headers': {
 'Content-Type': 'application/json',
 }
};

async function loadFileDetails() {
 try { 
 const fileIdElement = document.getElementById('fileIdNumber');
 const fileId = fileIdElement ? fileIdElement.dataset.fileId : null;

 if (!fileId) {
 console.error('File ID not found in the HTML.');
 return;
 }

 const expiresAt = Date.now() + 900 * 1000; // Add 60 seconds to the current timestamp
 console.log(new Date(expiresAt));

 const response = await fetch(
 '/_hcms/api/createfilelink',
 requestOptions
 );

 const formattedData = await response.json();
 const fileLinkElement = document.getElementById('file-link');
 const fileLinkElement2 = document.getElementById('file_link_href');

 if (fileLinkElement && fileLinkElement2) {
 fileLinkElement.textContent = formattedData.url;
 fileLinkElement2.href = formattedData.url;
 const expiresAtElement = document.createElement('span');

 // Use options to specify the date and time format
 const dateOptions = {
 year: 'numeric',
 month: 'short',
 day: 'numeric',
 hour: '2-digit',
 minute: '2-digit',
 second: '2-digit',
 timeZoneName: 'short',
 };

 expiresAtElement.textContent = `${new Date(formattedData.expiresAt).toLocaleString(undefined, dateOptions)}`;
 fileLinkElement.appendChild(expiresAtElement);
 } else {
 console.error('Element with id "file_link_href" not found.');
 }
 } catch (error) {
 console.error('Error fetching signed URL:', error.message);
 const fileLinkElement = document.getElementById('file-link');

 if (fileLinkElement) {
 fileLinkElement.textContent = 'Error: Failed to fetch signed URL.';
 } else {
 console.error('Element with id "file-link" not found.');
 }
 }
}

// Call the function to load file details
loadFileDetails(); 
</script>

```

This code is using module. What I want is if I insert this module more than 1 it keeps asking a fileId so if each Id is being inserted it auto detect and run the code and give each unique **SIGNED URL**

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 25, 2024, 10:55pm UTC](https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650/2 "2024-01-25T22:55:49Z")

</div>

Hi, @Jun22 👋 Thanks for your question and for including your code example. I’d like to invite some of our community members to the converstaion — hey @JBeatty @Anton @MatthiasWeber, do you have any recent experience with the project @Jun22 is working on?

Thank you for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [January 27, 2024, 2:33pm UTC](https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650/3 "2024-01-27T14:33:23Z")

</div>

Hello [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) Jaycee, I think no one is giving us some thoughts about this task. They keep on ignoring this post. Where is community on this side ugh.,. hope someone good person will sent some idea soon or never …

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [January 31, 2024, 10:17pm UTC](https://community.hubspot.com/t/hubspot-api-get-value-from-a-div-element/98650/4 "2024-01-31T22:17:01Z")

</div>

Hey, @Jun22 👋 I don’t think anyone is ignoring us. I think you asked a complex question with a large code block. The solutions provided in our community are primarily from other users, who are all volunteers. Can you provide a simplified example? And share the exact response you receive? This might help with troubleshooting. It could also be that what you are trying to do is not possible within the limitations with the endpoints you are accessing.

Best,

Jaycee
