mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 19:15:52 +01:00
Fix types
This commit is contained in:
@@ -80,19 +80,19 @@ class ApiClient {
|
||||
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);
|
||||
}
|
||||
|
||||
postText(url: string, payload: string, additionalHeaders = new Headers()) {
|
||||
postText(url: string, payload: string, additionalHeaders: Record<string, string> = {}) {
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
fileAppender(formData);
|
||||
|
||||
@@ -104,7 +104,7 @@ class ApiClient {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class ApiClient {
|
||||
method: string,
|
||||
url: string,
|
||||
contentType: string,
|
||||
additionalHeaders: Headers,
|
||||
additionalHeaders: Record<string, string>,
|
||||
payload?: any
|
||||
): Promise<Response> {
|
||||
const options: RequestInit = {
|
||||
@@ -141,7 +141,12 @@ class ApiClient {
|
||||
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 = {
|
||||
method: method,
|
||||
headers: additionalHeaders
|
||||
@@ -156,7 +161,7 @@ class ApiClient {
|
||||
if (!options.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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user