Add user settings page (#58)

* Several fixes

* User edit page
This commit is contained in:
Geometrically
2020-12-16 13:24:17 -07:00
committed by GitHub
parent 7934f65ae8
commit a38458c9be
9 changed files with 322 additions and 219 deletions

View File

@@ -11,6 +11,9 @@ import ModPage from '@/components/ModPage'
export default {
components: { ModPage },
auth: false,
async fetch() {
this.body = (await axios.get(this.mod.body_url)).data
},
async asyncData(data) {
const config = {
headers: {
@@ -27,38 +30,43 @@ export default {
)
).data
const [members, versions, body] = (
const [members, versions] = (
await Promise.all([
axios.get(
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
config
),
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
axios.get(
`https://api.modrinth.com/api/v1/versions?ids=${JSON.stringify(
mod.versions
)}`,
config
),
axios.get(mod.body_url),
])
).map((it) => it.data)
const users = await Promise.all(
members.map((it) =>
axios.get(`https://api.modrinth.com/api/v1/user/${it.user_id}`, config)
const users = (
await axios.get(
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
members.map((it) => it.user_id)
)}`,
config
)
)
users.forEach(
(it, index) => (members[index].avatar_url = it.data.avatar_url)
)
).data
users.forEach((it, index) => {
members[index].avatar_url = it.avatar_url
members[index].name = it.username
})
return {
mod,
body,
versions: versions.reverse(),
members,
}
},
data() {
return {
body: '',
}
},
head() {
return {
title: this.mod.title + ' - Modrinth',