Make payload parameter optional

This commit is contained in:
Florian Scholdei
2019-11-05 16:10:41 +01:00
parent d7d7c87d16
commit 5d7bdc24d4

View File

@@ -47,7 +47,7 @@ class ApiClient {
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);
}
@@ -82,11 +82,13 @@ class ApiClient {
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 = {
method: method,
body: JSON.stringify(payload)
method: method
};
if (payload) {
options.body = JSON.stringify(payload);
}
return this.httpRequestWithBinaryBody(options, url, contentType);
}