MCPcopy
hub / github.com/ampproject/amphtml / requestGithub

Function requestGithub

build-system/common/update-session-issues/index.js:120–143  ·  view source on GitHub ↗

* @param {string} token * @param {string} path * @param {Object=} data * @param {Object=} options * @return {!Promise }

(token, path, data, options = {})

Source from the content-addressed store, hash-verified

118 * @return {!Promise<Object>}
119 */
120async function requestGithub(token, path, data, options = {}) {
121 const {body, res} = await httpsRequest(
122 `https://api.github.com/${path.replace(/^\//, '')}`,
123 {
124 ...options,
125 method: options.method || 'GET',
126 headers: {
127 ...options.headers,
128 'Authorization': `token ${token}`,
129 'Content-Type': 'application/json',
130 'User-Agent': 'amphtml',
131 'Accept': 'application/vnd.github.v3+json',
132 },
133 },
134 data ? JSON.stringify(data) : undefined
135 );
136
137 if (res.statusCode < 200 || res.statusCode > 299) {
138 console./*OK*/ error(body);
139 throw new Error(res.statusCode);
140 }
141
142 return JSON.parse(body);
143}
144
145/**
146 * @param {string} token

Callers 3

postGithubFunction · 0.85
closeGithubIssueFunction · 0.85
getGithubIssuesFunction · 0.85

Calls 5

httpsRequestFunction · 0.85
stringifyMethod · 0.80
replaceMethod · 0.45
errorMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected