From 1f9222ad04bf746d55522e16a116f02c07bc3c2b Mon Sep 17 00:00:00 2001 From: Liyas Thomas Date: Tue, 2 Jun 2020 17:10:47 +0530 Subject: [PATCH] :sparkles: DELETE now supports request body --- pages/index.vue | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index f17a7241c..62d2769d6 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -220,7 +220,11 @@ :placeholder="$t('optional')" /> -
+
  • @@ -1588,8 +1592,10 @@ export default { this.showRequestModal = true }, method() { - // this.$store.commit('setState', { 'value': ["POST", "PUT", "PATCH"].includes(this.method) ? 'application/json' : '', 'attribute': 'contentType' }) - this.contentType = ["POST", "PUT", "PATCH"].includes(this.method) ? "application/json" : "" + // this.$store.commit('setState', { 'value': ["POST", "PUT", "PATCH", "DELETE"].includes(this.method) ? 'application/json' : '', 'attribute': 'contentType' }) + this.contentType = ["POST", "PUT", "PATCH", "DELETE"].includes(this.method) + ? "application/json" + : "" }, preRequestScript: function (val, oldVal) { this.uri = this.uri @@ -1868,7 +1874,7 @@ export default { return this.showPreRequestScript || httpValid(this.url) }, hasRequestBody() { - return ["POST", "PUT", "PATCH"].includes(this.method) + return ["POST", "PUT", "PATCH", "DELETE"].includes(this.method) }, pathName() { return this.path.match(/^([^?]*)\??/)[1] @@ -1939,7 +1945,7 @@ export default { if (key) requestString.push(`xhr.setRequestHeader('${key}', '${value}')`) }) } - if (["POST", "PUT", "PATCH"].includes(this.method)) { + if (["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) { let requestBody = this.rawInput ? this.rawParams : this.rawRequestBody if (isJSONContentType(this.contentType)) { requestBody = `JSON.stringify(${requestBody})` @@ -1968,7 +1974,7 @@ export default { } else if (this.auth === "Bearer Token" || this.auth === "OAuth 2.0") { headers.push(` "Authorization": "Bearer ${this.bearerToken}",\n`) } - if (["POST", "PUT", "PATCH"].includes(this.method)) { + if (["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) { let requestBody = this.rawInput ? this.rawParams : this.rawRequestBody if (isJSONContentType(this.contentType)) { requestBody = `JSON.stringify(${requestBody})` @@ -2015,7 +2021,7 @@ export default { if (key) requestString.push(` -H '${key}: ${value}' \n`) }) } - if (["POST", "PUT", "PATCH"].includes(this.method)) { + if (["POST", "PUT", "PATCH", "DELETE"].includes(this.method)) { const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody requestString.push(` -H 'Content-Length: ${requestBody.length}' \n`) requestString.push(` -H 'Content-Type: ${this.contentType}; charset=utf-8' \n`) @@ -2828,7 +2834,6 @@ export default { this._keyListener = function (e) { if (e.key === "g" && (e.ctrlKey || e.metaKey)) { e.preventDefault() - console.log(this.runningRequest) if (!this.runningRequest) { this.sendRequest() } else {