The Search Begins
This nearly took me 8 hours. I have no idea what is going on when it comes to Javascript. I think this is my first time properly having a go.
I gave up approximately 4 times. Every time I was restored by food and caffeine.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| public async getData() {
if (!this.data) {
// console.log('Form:', this.form); // Debugging statement
/// Not fetched yet
const jsonURL = this.form.dataset.json || '/search/index.json';
// console.log('jsonURL:', jsonURL); // Debugging statement
this.data = await fetch(jsonURL).then(res => res.json());
const parser = new DOMParser();
for (const item of this.data) {
item.content = parser.parseFromString(item.content, 'text/html').body.innerText;
}
}
return this.data;
}
|
This was the line that solved it:
|| ‘/search/index.json’;
ps. I’ve forgotten how to properly format my dates again.