Hello everyone, I’m new to the forum, new to InDesign, new to UXP, and too new to JavaScript to recognize slop when vibe coding. I’m hoping someone can point me in the right direction.
I’m creating an index for a 500 or so page genealogy book of my family. My brother is writing the book in InDesign and I’m working with Adobe’s UXP Developer Tools and JavaScript to support him. Our relative’s data resides in a substantial database collection written in Python so I’m calling a local server API (127.0.0.1) to use Natural Language Processing to find name/date_phrase entries from page contents passed to the API. I’m navigating through the book ultimately creating an index of all those references and topic levels drawn from the API response data.
Lengthy use case aside, I’m getting some unexpected behavior when calling the server from the UXP/InDesign environment. Repeated calls to my server API from a separate Python process works well taking on average 650ms to process each call.
The call to the API from InDesign/UXP hangs in the call stack until the debug script terminates. Even multiple calls to the API all initiate and resolve after the script terminates. I’ve messed with creating a promise and waiting for the response, but I’ve wasted a lot of time with various code hallucinations without any success.
I’d appreciate any human-experience with a clear direction helping me to get over the hump.
Thanks in advance,
Michael Lucido
Saint Louis, USA
SLIMMED DOWN VERSION OF API CALL
async function postData(data) {
try {
const response = await fetch(‘http://127.0.0.1:5000/api/submit’, {
method: ‘POST’,
headers: {‘Content-Type’: ‘application/json’},
body: JSON.stringify(data)});
const rspData = await response.json();
console.log(rspData);
} catch (error) {
console.error(error);
}
console.log("Async operation complete, script can now terminate.");
}
const testData = {sentence: “Antonino Lucido (1845-1940, Fig. 37) was born in IdF …”};
postData(testData);