Skip to content

Instantly share code, notes, and snippets.

@dennbagas
Created September 17, 2019 12:18
Show Gist options
  • Save dennbagas/351182a809aaa74dbb2359b7200f212e to your computer and use it in GitHub Desktop.
Save dennbagas/351182a809aaa74dbb2359b7200f212e to your computer and use it in GitHub Desktop.
Update ke 3 server.js
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