Created
September 17, 2019 12:18
-
-
Save dennbagas/351182a809aaa74dbb2359b7200f212e to your computer and use it in GitHub Desktop.
Update ke 3 server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const cors = require('cors'); | |
const weather = require("./weather"); | |
// update | |
const resource = require("./weather/resource"); | |
const app = express(); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(cors()); | |
// update | |
app.get('/weather', weather.index); | |
app.listen(4000, function () { | |
console.log('Example app listening on port 4000!'); | |
resource.get() | |
.then(() => { | |
const oneDayInMs = 86400000; | |
setInterval(() => weather.get(), oneDayInMs); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment