when res.render() method used, internal express server response error with status code 500

I am new to node.js and please be patient with me.I am experiencing difficulties with internal express server.
My goal is to make Get request and load the data from external server and render it on my website.Although I successfully loaded the data from external server and parse it into javascript object. When I console log it, I can see javascript object is correctly transformed. But when I render it on my ejs file, It was said that the array I passed is undefined. I spelled correctly variables names. Then I inspect it by using developer tool and I got the message in console as below

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

let me show the code I used

const express = require(“express”);

const bodyParser = require(“body-parser”);

const app = express();

app.set(‘view engine’, ‘ejs’);

app.use(bodyParser.urlencoded({

extended: true

}));

app.use(express.static(__dirname + “/public”));

// const ejs = require(“ejs”);

const https = require(‘https’);

app.get(“/Health”,function(req, res){

let healthUrl = “https://newsapi.org/v2/top-headlines/?

category=health&apiKey=5ad38a0db6944d22aa81b5420f6a62f4&language=en”;

https.get(healthUrl, (resp) => {

let data ='';




resp.on("data",(chunk)=>{




  data += chunk;




});




resp.on("end",()=>{




let newData =  JSON.parse(data);

let allArticles = newData.articles;

});

}).on(‘error’, (e) => {

console.error(e);

});

res.render(“Health”,{allArticles:allArticles});

});

when I console log(allArticles); in app.js file, I can see the javascript that I loaded. But when I render it on ejs file, error occered and got the message that “allArticles is undefined”
I checked it in ejs file like below:

%-include(‘partials/header’)-%>

<% console.log(allArticles) %>

<%-include(‘partials/footer’)-%>

then I inspect it by dev tool , as I mensioned above, I got the message like this:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)