Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import jsonData from "./json/data.json";
- //const jsonData = require('./json/data.json')
- async function calcWeather() {
- // let rawdata = fs.readFileSync("./json/data.json");
- // let data2 = JSON.parse(rawdata);
- // fs.readFile("./json/data.json", "utf8", function (err, data) {
- // if (err) throw err;
- // data2 = JSON.parse(data /*[0]*/);
- // console.log(typeof data2);
- for (let item of jsonData) {
- let base = `https://api.openweathermap.org/data/2.5/weather?lat=${item.latjson}&lon=${item.lonjson}&appid=${api_key}&units=metric&lang=sp`;
- fetch(base)
- .then((responses) => {
- return responses.json();
- })
- .then((data) => {
- var myObject = {
- Id_Oficina: item.IdOficina,
- Humedad: data.main.humidity,
- Nubes: data.clouds.all,
- Sensacion: data.main.feels_like,
- Temperatura: data.main.temp,
- Descripcion: data.weather.description,
- };
- // validation and saving data to array
- if (myObject.Temperatura < 99) {
- lstValid.push(myObject);
- }
- });
- }
- // });
- console.log(lstValid);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement