Build HTTP module (Make) with Code action (Pabbly) ?

Hey Guys,

I’m really missing the HTTP module that Make offers, so figured that with a little help of LLMs I could easily build this with the Code action in Pabbly.
Guess not.

Has anyone achieved this, or is it impossible?

This is what I came up with

JavaScript:
async function fetchHTMLContent(url) {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
    }
    const htmlContent = await response.text();
    return htmlContent;
  } catch (error) {
    console.error('Error:', error);
    return 'Error';
  }
}

// Example usage:
const url = 'https://example.com'; // Replace with the URL of the webpage you want to fetch
fetchHTMLContent(url)
  .then(htmlContent => {
    if (htmlContent && htmlContent !== 'Error') {
      console.log('HTML content:', htmlContent);
    } else {
      console.log('Failed to fetch HTML content.');
    }
  });
 
Use case is having a Code action with aforemention javascript code fetch the HTML source code of a given url.
Problem the action returns a blank output
 

ArshilAhmad

Well-known member
Staff member
We attempted to execute this code in an online JS compiler and encountered an error. Please verify whether the code is correct or not.
1714166924209.png
 
Top