gitlab-fetch
Advanced tools
Comparing version 0.2.0-dev.7535376 to 0.2.0-dev.7826013
@@ -34,3 +34,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [response, file] = yield this.fetchBody('GET', '/files', { ref: this.ref, file_path: path }); | ||
const [response, file] = yield this.fetchUnchecked('GET', '/files', { ref: this.ref, file_path: path }); | ||
if (response.status === 200) { | ||
@@ -37,0 +37,0 @@ return file; |
@@ -17,2 +17,4 @@ "use strict"; | ||
/** | ||
* @param config - Auth/deployment configuration. | ||
* @param baseApiPath - Base path of the API, to prepend to all requests. | ||
* @internal | ||
@@ -69,2 +71,9 @@ */ | ||
/** | ||
* Make a HTTP request and check that the response status is 2xx. | ||
* @param method - HTTP method. | ||
* @param path - Path to append to baseApiPath, or undefined to just use the baseApiPath. | ||
* @param params - Query params to add to URL. Stringified using the query-string package. | ||
* @param options - Extra request options | ||
* @return Promise of parsed response body (parsed JSON, Buffer or undefined). | ||
* @throws Error if response status is not 2xx. | ||
* @internal | ||
@@ -74,3 +83,3 @@ */ | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [response, body] = yield this.fetchBody(method, path, params, options); | ||
const [response, body] = yield this.fetchUnchecked(method, path, params, options); | ||
if (response.status < 200 || response.status >= 300) { | ||
@@ -84,5 +93,11 @@ debug_1.network(response); | ||
/** | ||
* Make a HTTP request. | ||
* @param method - HTTP method. | ||
* @param path - Path to append to baseApiPath, or undefined to just use the baseApiPath. | ||
* @param params - Query params to add to URL. Stringified using the query-string package. | ||
* @param options - Extra request options | ||
* @return Promise of response and parsed body (parsed JSON, Buffer or undefined). | ||
* @internal | ||
*/ | ||
fetchBody(method, path, params = {}, options = {}) { | ||
fetchUnchecked(method, path, params = {}, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -111,3 +126,3 @@ const response = yield this.rawFetch(method, path || '', params, undefined, options); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { baseApiPath = this.baseApiPath } = options; | ||
const { baseApiPath = this.baseApiPath, body } = options; | ||
this.enhanceHeaders(headers); | ||
@@ -123,2 +138,3 @@ let url = `${this.config.baseUrl}${baseApiPath}${path}`; | ||
headers, | ||
body: body !== undefined ? JSON.stringify(body) : undefined, | ||
}); | ||
@@ -125,0 +141,0 @@ debug_1.network('=> %d', response.status); |
export * from './branch'; | ||
export * from './comment'; | ||
export * from './commit'; | ||
export * from './commit-status'; | ||
export * from './compare-repository'; | ||
@@ -4,0 +6,0 @@ export * from './event'; |
{ | ||
"name": "gitlab-fetch", | ||
"version": "0.2.0-dev.7535376", | ||
"version": "0.2.0-dev.7826013", | ||
"author": "Jay Anslow <jay@anslow.me.uk>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73196
111
1368