mardi 27 août 2019

How to transfer data to a template without using EJS?

app.get("/movies",function(req,res){Movies.find({},function(err,foundMovie){
if(err){
    console.log(err);
}
else{
    res.render("movies/index",{movie_index:foundMovie});
}});});

I have this code that finds a movie and send that foundMovie to an EJS file. The route is created following RESTful routes. I can display anything about that foundMovie in my EJS file as I please. The EJS file then takes the foundMovie and manipulates it. Then the EJS file will be rendered by the app.js on the mentioned route.

My questions are following:

1- Since I dont wanna use EJS, how will transfer the data/foundMovie from the app.js to an HTML file.

2 - How will I use the data/foundMovie inside HTML file without using the EJS syntax (<%= movie_index.name%>)

Note: KIndly state your answer for NodeJS environment only.




Aucun commentaire:

Enregistrer un commentaire