Skip to content

Commit 5af15e4

Browse files
committed
add function in fetching the json file
TODO: create a display for the results
1 parent e3ca644 commit 5af15e4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

index.html

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,14 @@ <h3>Grab your own sweet-looking <span>.is-a.dev</span> subdomain.</h3>
6262

6363
<h2>Check SubDomain Availability</h2>
6464
<div class="search-cntnr">
65-
<input type="text" placeholder="Check domain name e.g. william">
66-
<div class="search-btn">
65+
<input id="subdomain" type="text" placeholder="Check domain name e.g. william">
66+
<div class="search-btn" onclick="{check()}">
6767
Check
6868
</div>
6969
</div>
70+
<div class="search-result-cntnr">
71+
<p>Perfect! The subdomain is not yet available, <a href="https://docs.is-a.dev">read more here</a> to register this subdomain!</p>
72+
</div>
7073

7174
<h2>Important Links</h2>
7275
<ul>
@@ -96,5 +99,23 @@ <h2>Donations</h2>
9699
A project by <a href="https://wdh.gg">William Harrison</a>.
97100
</p>
98101
</main>
102+
<script>
103+
function check(){
104+
fetch('https://raw.githubusercontent.com/is-a-dev/register/main/domains/'+document.getElementById('subdomain').value.trim().replace(' ','-').toLowerCase()+'.json')
105+
.then(response => {
106+
if (!response.ok) {
107+
throw new Error("HTTP error " + response.status);
108+
}
109+
return response.json();
110+
})
111+
.then(json => {
112+
// this.users = json;
113+
console.log(json);
114+
})
115+
.catch(function () {
116+
this.dataError = true;
117+
})
118+
}
119+
</script>
99120
</body>
100121
</html>

0 commit comments

Comments
 (0)