I used the sample code (below) but I get an error “Error: FetchError: Not Found” with the code below, but when I try the “shell code” (curl --request GET --url 'https://dollarvigilante.api-us1.com/api/3/contacts?search=null&segmentid=null&status=-1&orders%5Bid%5D=ASC&orders%5Bemail$5D=ASC' --header 'Api-Token: OURAPIKEY' --header 'accept: application/json'
) it works fine.
Here’s the code that says “Not Found”:
const port = 3222; // Choose a port that's not already in use
import activecampaign from '@api/activecampaign';
activecampaign.auth(OURAPIKEY);
async function processRequest(req) {
try {
const alac = await activecampaign.listAllContacts({
search: 'null',
segmentid: 'null',
status: '-1',
'filters[created_after]': '2025-05-01',
'orders[id]': 'ASC',
'orders[email]': 'ASC'
});
} catch(e) {
return "Caught Error: " + e.toString();
}
return alac;
}
async function makeHTML(req) {
// Your function to generate the HTML content
const page = await processRequest(req);
return `
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Page from NodeJS</title>
</head>
<body>
<h1>Hello from NodeJS!</h1>
<p>This content was dynamically generated.</p>
${page}
</body>
</html>
`;
I’m looking for ideas why it says “not found” for the Javascript, but provides results with curl.