Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Datasets field for applet trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
WJXHenry committed Mar 25, 2019
1 parent 3c6ccce commit 4d86953
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/controllers/open-data-datasets.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const request = require('request-promise-native')

function sortOrder(a, b) {
return a.label < b.label ? -1 : (a.label > b.label ? 1 : 0)
}

module.exports = async function(req, res) {
let datasets
try {
let rawJsonData = await request(process.env.OPEN_DATA_URL)
const rawData = JSON.parse(rawJsonData)
datasets = rawData.dataset.map(function(entry){
return entry.title
}).sort()
return { label: entry.title, value: entry.identifier }
}).sort(sortOrder)
console.log(datasets)
} catch (e) {
e.code = 500
throw e
Expand Down

0 comments on commit 4d86953

Please sign in to comment.