Here I am making a weather app. First I request and retrieve the data from first three lines and print in the console in the line forth. Since, node.js runs asynchronously the console.log() function runs before the data is retrieve. What should I do??
Code is:
//sending the request
const APIMannager = require("./locationToWeather.js");
const apiMannager = new APIMannager();
const data = apiMannager.getLocation("pokhara");
console.log(data); //prints undefined
//how to run the program one line after another