(method: string, url: string, data?: Record<string, unknown>)
| 147 | constructor(private token: string, private owner: string, private repo: string) {} |
| 148 | |
| 149 | private async request(method: string, url: string, data?: Record<string, unknown>) { |
| 150 | let query = ''; |
| 151 | let body = data; |
| 152 | |
| 153 | if (data && !hasBody(method)) { |
| 154 | query = toQuery(data); |
| 155 | body = undefined; |
| 156 | } |
| 157 | |
| 158 | const response = await fetch([this.apiBase, url, query].join(''), { |
| 159 | method, |
| 160 | headers: { |
| 161 | 'Content-Type': 'application/json;charset=UTF-8', |
| 162 | Accept: 'application/vnd.github.v3+json', |
| 163 | Authorization: `token ${this.token}`, |
| 164 | }, |
| 165 | body: body ? JSON.stringify(body) : undefined, |
| 166 | }); |
| 167 | |
| 168 | return response.json(); |
| 169 | } |
| 170 | |
| 171 | public async listMilestones(options: ListMilestonesOptions = {}): Promise<Milestone[]> { |
| 172 | const { state, sort, direction, page, pageSize } = options; |
no test coverage detected