-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGoogleCivicforHTML.js
More file actions
31 lines (27 loc) · 1013 Bytes
/
GoogleCivicforHTML.js
File metadata and controls
31 lines (27 loc) · 1013 Bytes
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
/* function createNode(element) {
return document.createElement(element);
}
function append(parent, el) {
return parent.appendChild(el);
}
const ul = document.getElementById('authors');
const url = 'https://randomuser.me/api/?results=10';
fetch(url)
.then((resp) => resp.json())
.then(function(data) {
let authors = data.results;
return authors.map(function(author) {
let li = createNode('li'),
img = createNode('img'),
span = createNode('span');
img.src = author.picture.medium;
span.innerHTML = `${author.name.first} ${author.name.last}`;
append(li, img);
append(li, span);
append(ul, li);
})
})
.catch(function(error) {
console.log(JSON.stringify(error));
}); */ // This doesn't actually work but I took it from a tutorial website - Brian.
//const url = 'https://www.googleapis.com/civicinfo/v2/representatives?key=AIzaSyA4cErjEnnOiGVvGHViWcl_sGXsM4CWdjI&address=';