I created this couple lines of code to mess around.
I have a list of movie titles from which I read in said titles with line-reader. If I console log line, I get back the original order, however, after calling the function the order becomes random.
my question is why, when I return a promise and use await.
Here's my code:
const axios = require("axios").default
//const db =require('./db')
const lineReader = require('line-reader');
lineReader.eachLine('./movies.txt', async function(line) {
    const movie=await getMovie(line)
    console.log(movie)
});
async function getMovie(title){
    return new Promise((resolve,reject)=>{
        axios.get("http://www.omdbapi.com/?t="+title+"&apikey=myapikey").then((result)=>{
            const data=result.data
            const movie={
                "id":data.imdbID,
                "title":data.Title,
                "year":data.Year+"-01-01",
                "runtime":data.Runtime,
                "genres":data.Genre,
                "director":data.Director,
                "plot":data.Plot,
                "rating":parseFloat(data.imdbRating)
            }
            //db.insert(movie)
            resolve(movie)
        });
    })
}
 
     
    