Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
produce valid output when showing/copying code
Hydrophobefireman764d001ef658
diff --git a/pages/index.vue b/pages/index.vueindex a8e110c6c..65a3707fa 100644--- a/pages/index.vue+++ b/pages/index.vue@@ -1941,7 +1941,7 @@ export default {requestString.push(`xhr.setRequestHeader('Content-Type', '${this.contentType}; charset=utf-8')`)- requestString.push(`xhr.send(${requestBody})`)+ requestString.push(`xhr.send("${requestBody}")`)} else {requestString.push("xhr.send()")}@@ -1960,7 +1960,13 @@ export default {headers.push(` "Authorization": "Bearer ${this.bearerToken}",\n`)}if (["POST", "PUT", "PATCH"].includes(this.method)) {- const requestBody = this.rawInput ? this.rawParams : this.rawRequestBody+ let requestBody = this.rawInput ? this.rawParams : this.rawRequestBody+ if (this.contentType.includes("json")) {+ requestBody = `JSON.stringify("${requestBody}")`;+ } else if (this.contentType.includes("x-www-form-urlencoded")) {+ requestBody = `"${requestBody}"`;+ }+requestString.push(` body: ${requestBody},\n`)headers.push(` "Content-Length": ${requestBody.length},\n`)headers.push(` "Content-Type": "${this.contentType}; charset=utf-8",\n`)