Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2020-12-11 01:37:15 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2020-12-11 01:37:15 +0300
commitb31a64bd2a22becee5bc2e49c32c3028491899f4 (patch)
treea00e7686cb09979d6892d98da8341a9acb50909e /src/Network
parent277f5a1571a1a839d4f000a8ef65e35cba5b05ce (diff)
Fix update function
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/ApiRequest.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Network/ApiRequest.js b/src/Network/ApiRequest.js
index 9a6af72..0be8cc8 100644
--- a/src/Network/ApiRequest.js
+++ b/src/Network/ApiRequest.js
@@ -13,6 +13,7 @@ export default class ApiRequest {
this._url = url;
this._path = null;
this._data = null;
+ this._method = null;
this._userAgent = null;
this._session = session;
this._responseType = 'application/json';
@@ -82,6 +83,17 @@ export default class ApiRequest {
* @param {String} value
* @return {ApiRequest}
*/
+ setMethod(value) {
+ this._method = value.toUpperCase();
+
+ return this;
+ }
+
+ /**
+ *
+ * @param {String} value
+ * @return {ApiRequest}
+ */
setUserAgent(value) {
this._userAgent = value;
@@ -128,13 +140,12 @@ export default class ApiRequest {
*/
_getRequestOptions() {
let headers = this._getRequestHeaders();
- let method = 'GET';
+ let method = this._method === null ? 'GET':this._method;
let options = {method, headers, credentials: 'omit', redirect: 'error'};
if(this._data !== null) {
options.body = JSON.stringify(this._data);
- method = 'POST';
+ if(method === 'GET') options.method = 'POST';
}
- options.method = method;
return options;
}