-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
37 lines (31 loc) · 963 Bytes
/
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
const fetch = require('isomorphic-unfetch')
exports.handler = (event, context, callback) => {
let search = event.pathParameters.search
let url = 'http://search.artsmia.org/' + search
const options = {
method: 'GET'
}
fetch(url, options)
.then(resp => resp.json())
.then(json => {
let data = json.hits.hits.map(({ _source }) => ({
medium: _source.medium,
title: _source.title,
date: _source.dated,
dimensions: _source.dimensions,
accessionNumber: _source.accession_number,
attribution: _source.artist,
culture: _source.culture || _source.country,
creditLine: _source.creditline,
currentLocation: _source.room,
description: _source.description || _source.text
}))
let result = {
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ data })
}
callback(null, result)
})
}