bugfix: request cannot be bound to repo url
This commit is contained in:
parent
f7fb01e3cb
commit
2277a9c479
@ -8,7 +8,7 @@ class API {
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.branch = branch;
|
this.branch = branch;
|
||||||
this.baseURL = API_ROOT + `/repos/${this.repo}`;
|
this.repoURL = `/repos/${this.repo}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
user() {
|
user() {
|
||||||
@ -20,7 +20,7 @@ class API {
|
|||||||
return cache.then((cached) => {
|
return cache.then((cached) => {
|
||||||
if (cached) { return cached; }
|
if (cached) { return cached; }
|
||||||
|
|
||||||
return this.request(`/contents/${path}`, {
|
return this.request(`${this.repoURL}/contents/${path}`, {
|
||||||
headers: { Accept: 'application/vnd.github.VERSION.raw' },
|
headers: { Accept: 'application/vnd.github.VERSION.raw' },
|
||||||
data: { ref: this.branch },
|
data: { ref: this.branch },
|
||||||
cache: false
|
cache: false
|
||||||
@ -35,7 +35,7 @@ class API {
|
|||||||
}
|
}
|
||||||
|
|
||||||
listFiles(path) {
|
listFiles(path) {
|
||||||
return this.request(`/contents/${path}`, {
|
return this.request(`${this.repoURL}/contents/${path}`, {
|
||||||
data: { ref: this.branch }
|
data: { ref: this.branch }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ class API {
|
|||||||
|
|
||||||
request(path, options = {}) {
|
request(path, options = {}) {
|
||||||
const headers = this.requestHeaders(options.headers || {});
|
const headers = this.requestHeaders(options.headers || {});
|
||||||
return fetch(this.baseURL + path, {...options, headers: headers}).then((response) => {
|
return fetch(API_ROOT + path, { ...options, headers: headers }).then((response) => {
|
||||||
if (response.headers.get('Content-Type').match(/json/)) {
|
if (response.headers.get('Content-Type').match(/json/)) {
|
||||||
return this.parseJsonResponse(response);
|
return this.parseJsonResponse(response);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user