192
193
private async _makeGHAPIRequest<T>(
195
>
method: 'GET' | 'POST',
196
>
token: string,
197
>
signal: AbortSignal,
198
>
body?: Record<string, unknown>,
199
>
etag?: string
200
>
): Promise<IGitHubApiResponse<T>> {
201
>
const url = `${this._endpoint.getApiBaseUri()}/${routeSlug}`;
202
>
const headers: Record<string, string> = {
203
>
'Accept': 'application/vnd.github+json',
204
>
'Authorization': `Bearer ${token}`,
205
>
'X-GitHub-Api-Version': GITHUB_API_VERSION,
206
>
};
207
>
if (etag) {
208
headers['If-None-Match'] = etag;
209
}
211
headers['Content-Type'] = 'application/json';
212
}
214
>
let response: Response;
215
>
try {
216
>
response = await this._fetch(url, {
217
>
method,
218
>
headers,
219
>
body: body ? JSON.stringify(body) : undefined,
220
>
signal,
221
>
});
222
>
} catch (err) {
223
if (signal.aborted) {
224
throw err;