mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 19:33:05 +00:00
31 lines
No EOL
1 KiB
JavaScript
31 lines
No EOL
1 KiB
JavaScript
export class ApiClient {
|
|
constructor(baseUrl) {
|
|
this.baseUrl = baseUrl
|
|
}
|
|
|
|
getBookmarks(query, options = {limit: 100, offset: 0}) {
|
|
const encodedQuery = encodeURIComponent(query)
|
|
const url = `${this.baseUrl}bookmarks/?q=${encodedQuery}&limit=${options.limit}&offset=${options.offset}`
|
|
|
|
return fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => data.results)
|
|
}
|
|
|
|
getArchivedBookmarks(query, options = {limit: 100, offset: 0}) {
|
|
const encodedQuery = encodeURIComponent(query)
|
|
const url = `${this.baseUrl}bookmarks/archived/?q=${encodedQuery}&limit=${options.limit}&offset=${options.offset}`
|
|
|
|
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)
|
|
}
|
|
} |