Skip to content

Commit

Permalink
fix: add proper ID and nameType to response
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmacdonald committed Aug 1, 2018
1 parent c79707f commit c17eb36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function getTitleLookupURI(queryString) {
return getEntitySourceURI(queryString, 'title')
}

function callCWRC(url, queryString) {
function callCWRC(url, queryString, nameType) {

return fetchWithTimeout(url, {credentials: 'same-origin'}).then((parsedJSON)=>{
console.log(parsedJSON)
Expand All @@ -75,26 +75,26 @@ function callCWRC(url, queryString) {
let id = record.solr_doc.PID
let name = record.solr_doc.fgs_label_s
let uri = entityRoot + '/'+ record.object_url
return {id: uri, uri, uriForDisplay: uri, name, repository: 'CWRC', originalQueryString: queryString}
return {id, uri, uriForDisplay: uri, name, nameType, repository: 'CWRC', originalQueryString: queryString}
}) : []
})

}

function findPerson(queryString) {
return callCWRC(getPersonLookupURI(queryString), queryString)
return callCWRC(getPersonLookupURI(queryString), queryString, 'person')
}

function findPlace(queryString) {
return callCWRC(getPlaceLookupURI(queryString), queryString)
return callCWRC(getPlaceLookupURI(queryString), queryString, 'place')
}

function findOrganization(queryString) {
return callCWRC(getOrganizationLookupURI(queryString), queryString)
return callCWRC(getOrganizationLookupURI(queryString), queryString, 'organization')
}

function findTitle(queryString) {
return callCWRC(getTitleLookupURI(queryString), queryString)
return callCWRC(getTitleLookupURI(queryString), queryString, 'title')
}

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test('findPerson', async function(assert){
uri: '',
uriForDisplay: '',
name: '',
nameType: '',
repository: '',
originalQueryString: ''
}), 'all results have correct keys')
Expand Down

0 comments on commit c17eb36

Please sign in to comment.