Fix data structure a little bit before returning
This commit is contained in:
parent
a2baedfb44
commit
2f2ed9697e
@ -2,6 +2,7 @@
|
||||
|
||||
const fetch = require('node-fetch')
|
||||
const xml2js = require('xml2js').parseString
|
||||
const _ = require('lodash')
|
||||
|
||||
const key = 'jRzwDtxiBV3vt6OQfQ'
|
||||
|
||||
@ -16,7 +17,11 @@ module.exports = {
|
||||
return reject(err)
|
||||
}
|
||||
|
||||
const results = json.GoodreadsResponse.search[0].results[0].work
|
||||
// because of xml > json we get a weird data structure. fix
|
||||
let results = json.GoodreadsResponse.search[0].results[0].work
|
||||
|
||||
// more fixing of the data structure
|
||||
results = results.map((result) => _.mapValues(result, (value, key) => value[0]))
|
||||
|
||||
resolve(results)
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user