I have a send HTTP requests in Branch 1 of a Router. After that request i have a CODE step. I am trying to read the content of HTTP body. How do I do that? I have this:
export const code = async ({ steps, inputs }) => {
const html = steps.step_3.body; //
CORRECT based on your output
const nameRegex = /TOPSNOW\d±INFO:[^N]NAME=([^\n])/g;
const snowRegex = /(\d+)\s*cm</small></td>/g;
const names = ;
const snows = ;
let m;
while ((m = nameRegex.exec(html)) !== null) names.push(m[1].trim());
while ((m = snowRegex.exec(html)) !== null) snows.push(parseInt(m[1], 10));
const top10 = names.map((name, i) => ({
name,
snow: snows[i] ?? 0
})).slice(0, 10);
let message = “![]()
Top 10 Next Snowfall (7 Day Forecast - Mid Mountain)\n\n”;
for (let i = 0; i < top10.length; i++) {
message += (i + 1) + “. " + top10[i].name + " — " + top10[i].snow + " cm\n”;
}
return { top10, message };
};