Skip to content

Commit

Permalink
Update datastore fetch to build columns from schema (#25)
Browse files Browse the repository at this point in the history
* Update datastore fetch to build columns from schema
  • Loading branch information
dgading authored Nov 9, 2021
1 parent bb8f047 commit aef035f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@civicactions/data-catalog-services",
"version": "1.0.0",
"version": "1.1.0",
"description": "Functions and React components to connect to the DKAN api.",
"main": "lib/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useDatastore/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export async function fetchDataFromQuery(id, rootUrl, options, additionalParams)
})
.then((res) => {
const { data } = res;
const propertyKeys = data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : [];
setValues(data.results),
setCount(data.count)
if(data.results.length) {
setColumns(prepareColumns ? prepareColumns(Object.keys(data.results[0])) : Object.keys(data.results[0]))
setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys)
}
setSchema(data.schema)
if(typeof setLoading === 'function') {
Expand Down

0 comments on commit aef035f

Please sign in to comment.