Skip to content
Snippets Groups Projects
Commit 296d7172 authored by Trirst's avatar Trirst
Browse files

Helper function for parsing query value

parent 2face179
No related branches found
No related tags found
No related merge requests found
<script>
import { onMount } from "svelte";
import { paths } from "@/static/js/paths";
import { fetchAPI } from "@/static/js/helper";
import { fetchAPI, getQueryValue } from "@/static/js/helper";
import ImageList from "@/lib/ImageList.svelte";
import PaginationBar from "@/lib/PaginationBar.svelte";
import { querystring } from "svelte-spa-router";
......@@ -10,7 +10,7 @@
let currentPage;
let lastPage;
$: if ($querystring !== "")
currentPage = parseInt(new URLSearchParams($querystring).get("p"));
currentPage = parseInt(getQueryValue($querystring, "p"));
$: getPageSnowflakes(currentPage - 1).then(
(snowflakes) => (pageSnowflakes = snowflakes || [])
);
......
......@@ -9,4 +9,8 @@ async function fetchAPI(endpoint, options) {
}
}
export { fetchAPI };
\ No newline at end of file
function getQueryValue(querystring, query) {
return new URLSearchParams(querystring).get(query)
}
export { fetchAPI, getQueryValue };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment