initial commit
This commit is contained in:
commit
155aa524f3
48 changed files with 3943 additions and 0 deletions
28
src/routes/user/[id]/+page.ts
Normal file
28
src/routes/user/[id]/+page.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { backend } from '$lib/backend';
|
||||
import { error, redirect } from '@sveltejs/kit';
|
||||
|
||||
export async function load(event) {
|
||||
const { params } = event;
|
||||
const { id } = params;
|
||||
|
||||
const resp = await backend.withEvent(event).fetch('user/' + encodeURIComponent(id));
|
||||
|
||||
if(resp.status === 404) {
|
||||
error(404);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const respJ = await resp.json();
|
||||
|
||||
let { users } = respJ;
|
||||
console.log(users);
|
||||
if (users[id]) {
|
||||
if (users[id].username) {
|
||||
redirect(302, "/@" +users[id].username );
|
||||
}
|
||||
}
|
||||
|
||||
error(404);
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue