| 200 | } |
| 201 | |
| 202 | export function createIssue(issueTerm: string, documentUrl: string, title: string, description: string, label: string) { |
| 203 | const url = `${UTTERANCES_API}/repos/${owner}/${repo}/issues${label ? `?label=${encodeURIComponent(label)}` : ''}`; |
| 204 | const request = new Request(url, { |
| 205 | method: 'POST', |
| 206 | body: JSON.stringify({ |
| 207 | title: issueTerm, |
| 208 | body: `# ${title}\n\n${description}\n\n[${documentUrl}](${documentUrl})` |
| 209 | }) |
| 210 | }); |
| 211 | request.headers.set('Accept', GITHUB_ENCODING__REST_V3); |
| 212 | request.headers.set('Authorization', `token ${token.value}`); |
| 213 | return fetch(request).then<Issue>(response => { |
| 214 | if (!response.ok) { |
| 215 | throw new Error('Error creating comments container issue'); |
| 216 | } |
| 217 | return response.json(); |
| 218 | }); |
| 219 | } |
| 220 | |
| 221 | export function postComment(issueNumber: number, markdown: string) { |
| 222 | const url = `repos/${owner}/${repo}/issues/${issueNumber}/comments`; |