-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (55 loc) · 2.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const express = require('express');
const ejs = require('ejs');
const axios = require("axios");
const app = express();
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'keyjeMS3U62hP7wfU'}).base('appDgNueeMhu1uIpy');
app.use(express.static('public'));
app.set('view engine', 'ejs');
app.get('/', function (req, res) {
res.render('pages/index');
});
app.get('/builds', function (req, res) {
res.render('pages/builds');
});
app.get('/hacks', function (req, res) {
res.render('pages/hackz');
});
app.get('/launches', function async (req, res) {
const projects = []
base('Accepted-Processed').select({
// Selecting the first 3 records in Grid view:
maxRecords: 10,
view: "Grid view",
fields : ['project_name', 'project_desc', 'cover_url', 'project_url']
}).eachPage(function page(records, fetchNextPage) {
// This function (`page`) will get called for each page of records.
records.forEach(function(record) {
console.log('Retrieved');
const name = record.get('project_name')
console.log(name);
const desc = record.get('project_desc')
console.log(desc);
const url = record.get('project_url')
console.log(url);
const cover = record.get('cover_url')
console.log(cover);
const project = {
name : name,
desc : desc,
url : url,
cover : cover
}
projects.push(project)
});
// To fetch the next page of records, call `fetchNextPage`.
// If there are more records, `page` will get called again.
// If there are no more records, `done` will get called.
fetchNextPage();
}, function done(err) {
res.render('pages/launches', {projects});
if (err) { console.error(err); return; }
});
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Server running on ${port}, http://localhost:${port}`));