I am using API to display movie search using express and axios when the user searches for a particular movie and I got some error after running the server.
Here is the express code:
var express = require("express");
const axios = require("axios");
var app = express();
app.set("view engine", "ejs");
app.get("/results", async function(req, res){
    try{
        const response = await axios.get('http://www.omdbapi.com/?s=hangover&apikey=thewdb');
        res.render("results", {data:response.data});
    }
    catch(err){
        console.log(err);
    }
});
app.listen(3000, function(){
    console.log("sever listening to port 3000");
});
 

 
    
Top comments (4)
It looks like the error is from the second bracket after the function definition inside the for loop.
So;
forEach(function(movie)) { ... }Would become;
forEach(function(movie) { ... })Thank you it was such a silly mistake and I couldn't find it!!
It looks like the closing bracket
)is in the wrong place, it should be after the closing curly bracket}I think, to closeforEach.Thank you it was such a silly mistake and I couldn't find it!!