fix(git-gateway): pass api URL instead of constructing it from repo value (#2631)

This commit is contained in:
melbourne2991
2019-09-27 02:35:52 +10:00
committed by Shawn Erquhart
parent dac67a93a0
commit 922c0f38ee
3 changed files with 9 additions and 17 deletions

View File

@ -70,22 +70,14 @@ export default class API extends GithubAPI {
return Promise.resolve(this.commitAuthor);
}
request(path, options = {}) {
request(path, options = {}, parseResponse = response => this.parseResponse(response)) {
const url = this.urlFor(path, options);
let responseStatus;
return this.getRequestHeaders(options.headers || {})
.then(headers => fetch(url, { ...options, headers }))
.then(response => {
responseStatus = response.status;
const contentType = response.headers.get('Content-Type');
if (contentType && contentType.match(/json/)) {
return this.parseJsonResponse(response);
}
const text = response.text();
if (!response.ok) {
return Promise.reject(text);
}
return text;
return parseResponse(response);
})
.catch(error => {
throw new APIError(error.message || error.msg, responseStatus, 'Git Gateway');