// api.js
let express = require("express");
let request = require("request");
const $url = "https://api2.sktelecom.com/weather/current/hourly";
let $lat = 37.539079;
let $lon = 126.990669;
const $key = "751d8762-5bcf-42b2-9121-f4bbeb68976d";
let $api = $url + "?lat=" + $lat + "&lon=" + $lon + "&appkey=" + $key;
request($api, function (error, response, body) {
let json = JSON.parse(body);
let weather = json.weather.hourly;
}
Put the data received as a request in weather
Please tell me how to transfer to another file called app.js
node.js
Let's modularize api.js App.js to api.I think there is a way to use callback when calling the js module.
In the current structure, it seems difficult to deliver the value to app.js.
© 2024 OneMinuteCode. All rights reserved.