Skip to content

Commit

Permalink
Merge pull request hoppscotch#693 from leomp12/fix/raw-input
Browse files Browse the repository at this point in the history
Fix raw input (JSON)
  • Loading branch information
liyasthomas authored Mar 22, 2020
2 parents 99ae80c + ed4f1fe commit e7e960e
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1432,8 +1432,17 @@ export default {
])
},
},
canListParameters(canToggleRaw) {
this.rawInput = !canToggleRaw
canListParameters: {
immediate: true,
handler(canListParameters) {
if (canListParameters) {
this.$nextTick(() => {
this.rawInput = Boolean(this.rawParams && this.rawParams !== "{}")
})
} else {
this.rawInput = true
}
},
},
contentType(contentType, oldContentType) {
const getDefaultParams = contentType => {
Expand Down Expand Up @@ -1529,11 +1538,6 @@ export default {
},
},
computed: {
/**
* These are content types that can be automatically
* serialized by postwoman.
*/
knownContentTypes: () => ["application/json", "application/x-www-form-urlencoded", "application/vnd.api+json"],
/**
* These are a list of Content Types known to Postwoman.
*/
Expand All @@ -1546,13 +1550,15 @@ export default {
"text/html",
"text/plain",
],
/**
* Check content types that can be automatically
* serialized by postwoman.
*/
canListParameters() {
return [
"application/json",
"application/hal+json",
"application/vnd.api+json",
"application/x-www-form-urlencoded",
].includes(this.contentType)
return (
this.contentType === "application/x-www-form-urlencoded" ||
this.contentType.endsWith("json")
)
},
uri: {
get() {
Expand Down Expand Up @@ -1839,7 +1845,7 @@ export default {
},
rawRequestBody() {
const { bodyParams, contentType } = this
if (contentType === "application/json") {
if (contentType.endsWith("json")) {
try {
const obj = JSON.parse(
`{${bodyParams
Expand Down

0 comments on commit e7e960e

Please sign in to comment.