databag/app/mobile/src/api/getContactChannelTopics.js

30 lines
787 B
JavaScript
Raw Normal View History

2022-09-07 07:32:06 +00:00
import { checkResponse, fetchWithTimeout } from './fetchUtil';
export async function getContactChannelTopics(server, token, channelId, revision, count, begin, end) {
let rev = ''
if (revision != null) {
rev = `&revision=${revision}`
}
let cnt = ''
if (count != null) {
cnt = `&count=${count}`
}
let bgn = ''
if (begin != null) {
bgn = `&begin=${begin}`
}
let edn = ''
if (end != null) {
edn = `&end=${end}`
}
2022-09-29 18:31:55 +00:00
let topics = await fetchWithTimeout(`https://${server}/content/channels/${channelId}/topics?contact=${token}${rev}${cnt}${bgn}${edn}`,
2022-09-07 07:32:06 +00:00
{ method: 'GET' });
checkResponse(topics)
return {
marker: topics.headers.get('topic-marker'),
revision: topics.headers.get('topic-revision'),
topics: await topics.json(),
}
}