b4c95a3b28
The old way did not properly handle escaping, e.g. if the value of a query param contained `&` or `=` inside it. By using url.searchParams.set, we can safely add these types of arguments to the path. Change-Id: I62d3883b14f9d5a517e4a3d58f019014b46fd1b4
35 lines
934 B
TypeScript
35 lines
934 B
TypeScript
// AUTOGENERATED BY private/apigen
|
|
// DO NOT EDIT.
|
|
|
|
import { HttpClient } from '@/utils/httpClient';
|
|
import { Time, UUID } from '@/types/common';
|
|
|
|
export class {
|
|
content: string;
|
|
}
|
|
|
|
export class {
|
|
id: UUID;
|
|
date: Time;
|
|
pathParam: string;
|
|
body: string;
|
|
}
|
|
|
|
export class docsHttpApiV0 {
|
|
private readonly http: HttpClient = new HttpClient();
|
|
private readonly ROOT_PATH: string = '/api/v0/docs';
|
|
|
|
public async (request: , path: string, id: UUID, date: Time): Promise<> {
|
|
const u = new URL(`${this.ROOT_PATH}/${path}`);
|
|
u.searchParams.set('id', id);
|
|
u.searchParams.set('date', date);
|
|
const path = u.toString();
|
|
const response = await this.http.post(path, JSON.stringify(request));
|
|
if (response.ok) {
|
|
return response.json().then((body) => body as );
|
|
}
|
|
const err = await response.json();
|
|
throw new Error(err.error);
|
|
}
|
|
}
|