Seeing how the request and request-promise packages are now deprecated, has anyone attempted using the node-fetch package with this yet?
Edit: I was able to make it work with the node-fetch package using your code with slight modifications:
const fetch = require('node-fetch');
const url = 'http://api.weatherapi.com/v1/current.json?key=c5aab2441e9248e49ee81903201910&q=bucharest';
setInterval(() => {
fetch(url)
.then(res => res.json())
.then(json => {
let code = json.current.condition.code;
switch (code) {
case 1000:
mp.world.weather = 'EXTRASUNNY'
break;
case 1003:
mp.world.weather = 'CLOUDS'
break;
case 1006:
mp.world.weather = 'CLOUDS'
break;
case 1066:
mp.world.weather = 'SNOW'
break;
case 1135:
mp.world.weather = 'FOGGY'
break;
case 1183:
mp.world.weather = 'RAIN'
break;
case 1189:
mp.world.weather = 'RAIN'
break;
case 1273:
mp.world.weather = 'THUNDER'
break;
default:
mp.world.weather = 'CLEAR'
}
console.log("[WEATHER-SYNC] Server weather is synced with Bucharest (" + json.current.condition.text + ")");
})
.catch(function(err){
console.log("There was an error running the weather.js script ! ", err)
});
}, 600000)
(I had to convert it back to your format, as I made modifications for my own usage, so if something is broken, please let me know).
Additionally, instead of using the deprecated request and request-promise packages, I used the node-fetch package instead:
npm i node-fetch
Hopefully this helps!
Edit #2: For the new people, please change the key in the URL to your own!