Rewrite
This commit is contained in:
parent
ce7957e0bf
commit
d8670ecf81
18 changed files with 191 additions and 193 deletions
|
@ -2,25 +2,21 @@ import { redirect } from '@sveltejs/kit';
|
|||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export async function load({ fetch, params, url }) {
|
||||
var search = url.searchParams;
|
||||
|
||||
var voteType = search.get('vote');
|
||||
|
||||
var id = params.post;
|
||||
|
||||
if (voteType) {
|
||||
var voteRes = await fetch(`/api/vote?post=${id}&vote=${voteType}`);
|
||||
var voteJson = await voteRes.text();
|
||||
|
||||
if (voteJson == 'fail') {
|
||||
throw redirect(302, '/account');
|
||||
}
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/post?post=${id}`);
|
||||
const postJson = await res.json();
|
||||
var f = (new FormData());
|
||||
|
||||
f.append('id',id);
|
||||
const res = await fetch(`/api/postGet`, {
|
||||
method: 'POST',
|
||||
body: f
|
||||
});
|
||||
const postJson = (await res.json()).data;
|
||||
|
||||
console.log(postJson);
|
||||
|
||||
return postJson;
|
||||
}
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
/** @type {import('./$types').ActionData} */
|
||||
export let form;
|
||||
</script>
|
||||
|
||||
<Post
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue