mirror of
https://github.com/pawelmalak/flame.git
synced 2026-02-28 09:23:12 +08:00
Created Cron job to get data from external api every 15 minutes and save it to local database. Created Weather model and controller to get latest weather status
This commit is contained in:
11
utils/jobs.js
Normal file
11
utils/jobs.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const schedule = require('node-schedule');
|
||||
const getExternalWeather = require('./getExternalWeather');
|
||||
|
||||
const weatherJob = schedule.scheduleJob('updateWeather', '0 */15 * * * *', async () => {
|
||||
try {
|
||||
await getExternalWeather();
|
||||
console.log('weather updated');
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user