Rework URL construction
This commit is contained in:
parent
5fda42856d
commit
5168ccaf62
@ -78,13 +78,19 @@ function navigateToAdd() {
|
||||
|
||||
function filter(filterString) {
|
||||
filterString = filterString.toUpperCase();
|
||||
const fetchURL = apiEndpoint + "?type=" + encodeURIComponent(filterString) + "&size=" + defaultPagingValue;
|
||||
|
||||
let fetchURL = new URL(apiEndpoint);
|
||||
fetchURL.searchParams.append("type", filterString);
|
||||
fetchURL.searchParams.append("size", defaultPagingValue);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
fetchQuery(fetchURL);
|
||||
}
|
||||
|
||||
function search(searchString) {
|
||||
const fetchURL = apiEndpoint + "/search" + "?search=" + encodeURIComponent(searchString.length === 0?"%":searchString);
|
||||
let fetchURL = new URL(apiEndpoint + "/search");
|
||||
fetchURL.searchParams.append("search", searchString.length == 0 ? "%" : searchString);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
fetchQuery(fetchURL);
|
||||
}
|
||||
@ -96,14 +102,22 @@ function sort(sortString) {
|
||||
} else {
|
||||
query[1] = "desc";
|
||||
}
|
||||
const fetchURL = apiEndpoint + "?sort=" + query[0] + "&direction=" + query[1];
|
||||
|
||||
let fetchURL = new URL(apiEndpoint);
|
||||
fetchURL.searchParams.append("sort", query[0]);
|
||||
fetchURL.searchParams.append("direction", query[1]);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
fetchQuery(fetchURL);
|
||||
}
|
||||
|
||||
function vote(entryID, up) {
|
||||
console.log(apiEndpoint + "/id/" + entryID + "/" + (up ? "upvote" : "downvote")); // TODO: remove
|
||||
fetch(apiEndpoint + "/id/" + entryID + "/" + (up ? "upvote" : "downvote"));
|
||||
const fetchURL = new URL(
|
||||
`${apiEndpoint}/id/${entryID}/${up ? "up" : "down"}vote`
|
||||
);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
fetch(fetchURL);
|
||||
}
|
||||
|
||||
function incrementPageCount() {
|
||||
|
Loading…
Reference in New Issue
Block a user