data = {
let opts = {'Api-User-Agent': 'wtf_wikipedia example'}
let doc = await wtf.fetch('List of Apollo astronauts', opts)
let s = doc.sections('Apollo astronauts who walked on the Moon')
let list = s.tables()[0].json()
s = doc.sections('Apollo astronauts who flew to the Moon without landing')
let list2 = s.tables()[0].json()
list = list.concat(list2)
let data = list.map(row => {
let result = {
name: '',
mission: ''
}
console.log(row)
if (row.Name) {
result.name = row.Name.text
if (row.links) {
result.name = row.links[0].page
}
}
if (row.Mission) {
result.mission = row.Mission.text
}
return result
})
return data
}