mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Make payload parameter optional
This commit is contained in:
@@ -47,7 +47,7 @@ class ApiClient {
|
|||||||
return fetch(createUrl(url), applyFetchOptions({})).then(handleFailure);
|
return fetch(createUrl(url), applyFetchOptions({})).then(handleFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
post(url: string, payload: any, contentType = "application/json") {
|
post(url: string, payload?: any, contentType = "application/json") {
|
||||||
return this.httpRequestWithJSONBody("POST", url, contentType, payload);
|
return this.httpRequestWithJSONBody("POST", url, contentType, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +82,13 @@ class ApiClient {
|
|||||||
return fetch(createUrl(url), options).then(handleFailure);
|
return fetch(createUrl(url), options).then(handleFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
httpRequestWithJSONBody(method: string, url: string, contentType: string, payload: any): Promise<Response> {
|
httpRequestWithJSONBody(method: string, url: string, contentType: string, payload?: any): Promise<Response> {
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
method: method,
|
method: method
|
||||||
body: JSON.stringify(payload)
|
|
||||||
};
|
};
|
||||||
|
if (payload) {
|
||||||
|
options.body = JSON.stringify(payload);
|
||||||
|
}
|
||||||
return this.httpRequestWithBinaryBody(options, url, contentType);
|
return this.httpRequestWithBinaryBody(options, url, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user