I've been doing some reading on modularizing my code and decided to export some functions to a separate file and include them in my main function once it's called.
So I have two files, index.js
and weather.js
.
In my weather.js
file I have :
"use strict";
exports.sometest = sometest;
function sometest() {
request('http://api.openweathermap.org/data/2.5/weather?&appid=' + process.env.weather_api_key + '', (error, response, body) => {
return body;
});
}
Then in my index.js
file I include it const testing = require("../../../lib/weather");
.
So how can I user the data I return within the function I've created? And could someone explain to me how it works, I'm a little confused in terms of scoping and syntax etc
Thank you.