mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05: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);
|
||||
}
|
||||
|
||||
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()) {
|
||||
const formData = new FormData();
|
||||
fileAppender(formData);
|
||||
@@ -133,6 +141,15 @@ class ApiClient {
|
||||
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) {
|
||||
options = applyFetchOptions(options);
|
||||
if (contentType) {
|
||||
|
||||
Reference in New Issue
Block a user