| 87 | |
| 88 | transformResponse: async (response: Response, params?: JiraGetAttachmentsParams) => { |
| 89 | const fetchAttachments = async (cloudId: string) => { |
| 90 | const attachmentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey?.trim() ?? ''}?fields=attachment` |
| 91 | const attachmentsResponse = await fetch(attachmentsUrl, { |
| 92 | method: 'GET', |
| 93 | headers: { |
| 94 | Accept: 'application/json', |
| 95 | Authorization: `Bearer ${params!.accessToken}`, |
| 96 | }, |
| 97 | }) |
| 98 | |
| 99 | if (!attachmentsResponse.ok) { |
| 100 | let message = `Failed to get attachments from Jira issue (${attachmentsResponse.status})` |
| 101 | try { |
| 102 | const err = await attachmentsResponse.json() |
| 103 | message = err?.errorMessages?.join(', ') || err?.message || message |
| 104 | } catch (_e) {} |
| 105 | throw new Error(message) |
| 106 | } |
| 107 | |
| 108 | return attachmentsResponse.json() |
| 109 | } |
| 110 | |
| 111 | let data: any |
| 112 | |