mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Add post and put with text
This commit is contained in:
@@ -84,6 +84,14 @@ class ApiClient {
|
|||||||
return this.httpRequestWithJSONBody("POST", url, contentType, additionalHeaders, payload);
|
return this.httpRequestWithJSONBody("POST", url, contentType, additionalHeaders, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
postText(url: string, payload: string, additionalHeaders = new Headers()) {
|
||||||
|
return this.httpRequestWithTextBody("POST", url, additionalHeaders, payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
putText(url: string, payload: string, additionalHeaders = new Headers()) {
|
||||||
|
return this.httpRequestWithTextBody("PUT", url, additionalHeaders, payload);
|
||||||
|
}
|
||||||
|
|
||||||
postBinary(url: string, fileAppender: (p: FormData) => void, additionalHeaders = new Headers()) {
|
postBinary(url: string, fileAppender: (p: FormData) => void, additionalHeaders = new Headers()) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
fileAppender(formData);
|
fileAppender(formData);
|
||||||
@@ -133,6 +141,15 @@ class ApiClient {
|
|||||||
return this.httpRequestWithBinaryBody(options, url, contentType);
|
return this.httpRequestWithBinaryBody(options, url, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
httpRequestWithTextBody(method: string, url: string, additionalHeaders: Headers, payload: string) {
|
||||||
|
const options: RequestInit = {
|
||||||
|
method: method,
|
||||||
|
headers: additionalHeaders
|
||||||
|
};
|
||||||
|
options.body = payload;
|
||||||
|
return this.httpRequestWithBinaryBody(options, url, "text/plain");
|
||||||
|
}
|
||||||
|
|
||||||
httpRequestWithBinaryBody(options: RequestInit, url: string, contentType?: string) {
|
httpRequestWithBinaryBody(options: RequestInit, url: string, contentType?: string) {
|
||||||
options = applyFetchOptions(options);
|
options = applyFetchOptions(options);
|
||||||
if (contentType) {
|
if (contentType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user