aboutsummaryrefslogtreecommitdiff
path: root/src/client/apis/hypothesis/HypothesisApiUtils.ts
blob: dc7e1f988e896517a126ccb9ab047d953d407577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export namespace Hypothesis {
    export const getAnnotation = async (username: String, searchParam: String) => {
        const base = 'https://api.hypothes.is/api/search';
        const request = base + `?user=acct:${username}@hypothes.is&text=${searchParam}`;
        console.log("DASH Querying " + request);
        const response = await fetch(request);
        if (response.ok) {
            return response.json();
        } else {
            throw new Error('DASH: Error in GET request');
        }
    };

    export const makeAnnotationUrl = (annotationId: string, baseUrl: string) => {
        return `https://hyp.is/${annotationId}/${baseUrl}`;
    };
}