diff --git a/codewars-badge.js b/codewars-badge.js
index 7c26060..cdc0a39 100644
--- a/codewars-badge.js
+++ b/codewars-badge.js
@@ -1,13 +1,9 @@
-// This native web component fetches data from the Codewars API and renders it as a badge
-// Here is some information about web component https://developer.mozilla.org/en-US/docs/Web/Web_Components
-// Here is the link to the Codewars API Docs: https://dev.codewars.com/#get-user
-
class CodeWarsBadge extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
- this.userName = "CodeYourFuture";
- this.userData = [];
+ this.userName = "fhkahin";
+ this.userData = {};
}
connectedCallback() {
@@ -26,26 +22,33 @@ class CodeWarsBadge extends HTMLElement {
`https://www.codewars.com/api/v1/users/${this.userName}`
);
const data = await response.json();
- this.userData = data; // set the userData property with the fetched data
+ this.userData = data;
+ return data;
}
render() {
this.shadowRoot.innerHTML = `
-
-
- ${this.userData.ranks.overall.name}
- `;
+
+
+
+ `;
}
}
customElements.define("codewars-badge", CodeWarsBadge);
+
+
diff --git a/index.html b/index.html
index bbb3149..acafb21 100644
--- a/index.html
+++ b/index.html
@@ -9,9 +9,15 @@
content="Extending HTML to create a new component"
/>
+
+
+ Overall Rank
+ ${this.userData.ranks.overall.name}
+ ${this.userData.ranks.overall.score}
+
+
+ JavaScript Rank
+ ${this.userData.ranks.languages.javascript.name}
+ ${this.userData.ranks.languages.javascript.score}
+
+
+ Total Challenges Completed
+ ${this.userData.codeChallenges.totalCompleted}
+