Merge remote-tracking branch 'origin/implement-js' into 22-integrate-api-and-frontend
This commit is contained in:
commit
ab92c7973f
@ -1,6 +1,7 @@
|
||||
import { fetchQuery } from "./contentUtility.js";
|
||||
|
||||
const apiEndpoint = "/api/v1/datasets";
|
||||
const baseURL = location.origin;
|
||||
const defaultPagingValue = 20;
|
||||
const lastQuery = {
|
||||
url: "",
|
||||
@ -79,7 +80,7 @@ function navigateToAdd() {
|
||||
function filter(filterString) {
|
||||
filterString = filterString.toUpperCase();
|
||||
|
||||
let fetchURL = new URL(apiEndpoint);
|
||||
let fetchURL = new URL(apiEndpoint, baseURL);
|
||||
fetchURL.searchParams.append("type", filterString);
|
||||
fetchURL.searchParams.append("size", defaultPagingValue);
|
||||
|
||||
@ -88,7 +89,7 @@ function filter(filterString) {
|
||||
}
|
||||
|
||||
function search(searchString) {
|
||||
let fetchURL = new URL(apiEndpoint + "/search");
|
||||
let fetchURL = new URL(apiEndpoint + "/search", baseURL);
|
||||
fetchURL.searchParams.append("search", searchString.length == 0 ? "%" : searchString);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
@ -103,7 +104,7 @@ function sort(sortString) {
|
||||
query[1] = "desc";
|
||||
}
|
||||
|
||||
let fetchURL = new URL(apiEndpoint);
|
||||
let fetchURL = new URL(apiEndpoint, baseURL);
|
||||
fetchURL.searchParams.append("sort", query[0]);
|
||||
fetchURL.searchParams.append("direction", query[1]);
|
||||
|
||||
@ -113,7 +114,8 @@ function sort(sortString) {
|
||||
|
||||
function vote(entryID, up) {
|
||||
const fetchURL = new URL(
|
||||
`${apiEndpoint}/id/${entryID}/${up ? "up" : "down"}vote`
|
||||
`${apiEndpoint}/id/${entryID}/${up ? "up" : "down"}vote`,
|
||||
baseURL,
|
||||
);
|
||||
|
||||
console.log(fetchURL); // TODO: remove
|
||||
|
Loading…
Reference in New Issue
Block a user