Skip to content

Instantly share code, notes, and snippets.

@Mythbusters123
Created September 4, 2021 13:14
Show Gist options
  • Save Mythbusters123/b1c61471e8f54ae7fcc0d9b7c0995915 to your computer and use it in GitHub Desktop.
Save Mythbusters123/b1c61471e8f54ae7fcc0d9b7c0995915 to your computer and use it in GitHub Desktop.
import axios from "axios";
import Head from "next/head";
import { Component } from "react";
import styles from "../../styles/Home.module.css";
export default class MythicAddons extends Component {
constructor() {
super({});
this.json;
console.log(this.getJson)
}
state = {
Jars: this.convertJson(),
};
componentDidMount() {
this.setState({ Jars: this.convertJson() });
}
render() {
const jars = this.state.Jars?.forEach((k, v) => {
return (
<li key={v}>
<a href={k}>{v}</a>
</li>
);
});
return (
<div>
<Head>
<meta
name="description"
content="Downloads for MythicAddons, all versions"
/>
<title>Downloads -- MythicAddons</title>
<link href="/favicon.ico" rel="icon" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>MythicAddons Downloads</h1>
<h3 className={styles.description}>
<ul>{jars}</ul>
</h3>
</main>
</div>
);
}
async getJson() {
return await (
await axios.get("http://localhost:3000/api/downloads/mythic-addons")
).data;
}
convertJson() {
return new Map(
Object.entries(
this.getJson().then((json) => {
return json;
})
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment