Skip to content

Commit

Permalink
airtable json to be used in react > relates #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Dupree committed Oct 5, 2018
1 parent 8c2cdd9 commit 66adf9c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions controllers/airtable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// const https = require('https')
// const querystring = require('querystring')
const request = require('request')
let storageUpdaterArr = [];
let airtableArr = [];

module.exports = (req, res, next) => {

Expand All @@ -13,7 +15,6 @@ module.exports = (req, res, next) => {
var base = Airtable.base('apphdQNWTLdRQbOOg');

// set up storageUpdaterArr array to be sent to
let storageUpdaterArr = [];

// start query to update airtable view no_geolocation
base('fonthilldummy').select({
Expand Down Expand Up @@ -72,8 +73,8 @@ module.exports = (req, res, next) => {
},
// set up api call to get airtable data
base('fonthilldummy').select({
maxRecords: 1,
pageSize: 3,
maxRecords: 100,
pageSize: 100,
view: "Grid view"
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function (record) {
Expand All @@ -83,13 +84,13 @@ module.exports = (req, res, next) => {
postcode: record.fields.Postcode,
coordinates: record.fields.geolocation
}
// console.log(airtableObj);
airtableArr.push(airtableObj);
})
fetchNextPage();
},
function done(err) {
if (err) { console.error(err); next(err); }
res.send(airtableObj)
res.send({ ...airtableArr })
}
)

Expand Down

0 comments on commit 66adf9c

Please sign in to comment.