mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 19:45:51 +01:00
Fix types
This commit is contained in:
@@ -80,19 +80,19 @@ class ApiClient {
|
|||||||
return fetch(createUrl(url), applyFetchOptions({})).then(handleFailure);
|
return fetch(createUrl(url), applyFetchOptions({})).then(handleFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
post(url: string, payload?: any, contentType = "application/json", additionalHeaders = new Headers()) {
|
post(url: string, payload?: any, contentType = "application/json", additionalHeaders: Record<string, string> = {}) {
|
||||||
return this.httpRequestWithJSONBody("POST", url, contentType, additionalHeaders, payload);
|
return this.httpRequestWithJSONBody("POST", url, contentType, additionalHeaders, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
postText(url: string, payload: string, additionalHeaders = new Headers()) {
|
postText(url: string, payload: string, additionalHeaders: Record<string, string> = {}) {
|
||||||
return this.httpRequestWithTextBody("POST", url, additionalHeaders, payload);
|
return this.httpRequestWithTextBody("POST", url, additionalHeaders, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
putText(url: string, payload: string, additionalHeaders = new Headers()) {
|
putText(url: string, payload: string, additionalHeaders: Record<string, string> = {}) {
|
||||||
return this.httpRequestWithTextBody("PUT", url, additionalHeaders, payload);
|
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: Record<string, string> = {}) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
fileAppender(formData);
|
fileAppender(formData);
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class ApiClient {
|
|||||||
return this.httpRequestWithBinaryBody(options, url);
|
return this.httpRequestWithBinaryBody(options, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
put(url: string, payload: any, contentType = "application/json", additionalHeaders = new Headers()) {
|
put(url: string, payload: any, contentType = "application/json", additionalHeaders: Record<string, string> = {}) {
|
||||||
return this.httpRequestWithJSONBody("PUT", url, contentType, additionalHeaders, payload);
|
return this.httpRequestWithJSONBody("PUT", url, contentType, additionalHeaders, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class ApiClient {
|
|||||||
method: string,
|
method: string,
|
||||||
url: string,
|
url: string,
|
||||||
contentType: string,
|
contentType: string,
|
||||||
additionalHeaders: Headers,
|
additionalHeaders: Record<string, string>,
|
||||||
payload?: any
|
payload?: any
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
@@ -141,7 +141,12 @@ class ApiClient {
|
|||||||
return this.httpRequestWithBinaryBody(options, url, contentType);
|
return this.httpRequestWithBinaryBody(options, url, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRequestWithTextBody(method: string, url: string, additionalHeaders: Headers, payload: string) {
|
httpRequestWithTextBody(
|
||||||
|
method: string,
|
||||||
|
url: string,
|
||||||
|
additionalHeaders: Record<string, string> = {},
|
||||||
|
payload: string
|
||||||
|
) {
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
method: method,
|
method: method,
|
||||||
headers: additionalHeaders
|
headers: additionalHeaders
|
||||||
@@ -156,7 +161,7 @@ class ApiClient {
|
|||||||
if (!options.headers) {
|
if (!options.headers) {
|
||||||
options.headers = new Headers();
|
options.headers = new Headers();
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore We are sure that here we only get headers of type Record<string, string>
|
||||||
options.headers["Content-Type"] = contentType;
|
options.headers["Content-Type"] = contentType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user