mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-10 06:04:15 +00:00
0975914a86
* Rename BookmarkFilters to BookmarkSearch * Refactor queries to accept BookmarkSearch * Sort query by data added and title * Ensure pagination respects search parameters * Ensure tag cloud respects search parameters * Ensure user select respects search parameters * Ensure return url respects search options * Fix passing search options to user select * Fix BookmarkSearch initialization * Extract common search form logic * Ensure partial update respects search options * Add sort UI * Use custom ICU collation when sorting with SQLite * Support sort in API
29 lines
870 B
JavaScript
29 lines
870 B
JavaScript
export class ApiClient {
|
|
constructor(baseUrl) {
|
|
this.baseUrl = baseUrl;
|
|
}
|
|
|
|
listBookmarks(search, options = { limit: 100, offset: 0, path: "" }) {
|
|
const query = [`limit=${options.limit}`, `offset=${options.offset}`];
|
|
Object.keys(search).forEach((key) => {
|
|
const value = search[key];
|
|
if (value) {
|
|
query.push(`${key}=${encodeURIComponent(value)}`);
|
|
}
|
|
});
|
|
const queryString = query.join("&");
|
|
const url = `${this.baseUrl}bookmarks${options.path}/?${queryString}`;
|
|
|
|
return fetch(url)
|
|
.then((response) => response.json())
|
|
.then((data) => data.results);
|
|
}
|
|
|
|
getTags(options = { limit: 100, offset: 0 }) {
|
|
const url = `${this.baseUrl}tags/?limit=${options.limit}&offset=${options.offset}`;
|
|
|
|
return fetch(url)
|
|
.then((response) => response.json())
|
|
.then((data) => data.results);
|
|
}
|
|
}
|