-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.js
24 lines (21 loc) · 795 Bytes
/
data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//import { setList } from "./template.js";
import * as $ from "./template.js";
const searchInput = document.querySelector('#search');
searchInput.addEventListener('keyup', search);
/* function search(event) {
if (event && event.keyCode === 13) {
const searchQuery = searchInput.value;
fetch(`https://api.github.com/search/repositories?q=${searchQuery}`)
.then(response => response.json())
.then(response => response.items)
.then($.setList);
}
} */
export default async function search(event) {
if (event && event.keyCode === 13) {
const searchQuery = searchInput.value;
let response = await fetch(`https://api.github.com/search/repositories?q=${searchQuery}`)
response = await response.json();
$.setList(response.items);
}
}